db

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyChainID                = "chain_id"
	KeyLastProcessedHeight    = "last_processed_height"
	KeyUptimeLookBackDuration = "uptime_look_back_duration"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Address       string `gorm:"primary_key"`
	Balance       string `gorm:"not null"`
	UpdatedHeight int64  `gorm:"not null"`
}

type BandDB

type BandDB struct {
	StakingKeeper staking.Keeper
	// contains filtered or unexported fields
}

func NewDB

func NewDB(dialect, path string, metadata map[string]string) (*BandDB, error)

func (*BandDB) AddBlock

func (b *BandDB) AddBlock(
	height int64,
	timestamp time.Time,
	proposer common.HexBytes,
	blockHash []byte,
) error

func (*BandDB) AddDataSource

func (b *BandDB) AddDataSource(
	id int64,
	name, description string,
	owner sdk.AccAddress,
	fee sdk.Coins,
	executable []byte,
	blockTime time.Time,
	blockHeight int64,
	txHash []byte,
) error

func (*BandDB) AddDelegation

func (b *BandDB) AddDelegation(
	delegatorAddress sdk.AccAddress,
	operatorAddress sdk.ValAddress,
	Coin sdk.Coin,
) error

func (*BandDB) AddOracleScript

func (b *BandDB) AddOracleScript(
	id int64,
	name, description string,
	owner sdk.AccAddress,
	code []byte,
	blockTime time.Time,
	blockHeight int64,
	txHash []byte,
) error

func (*BandDB) AddRawDataRequests

func (b *BandDB) AddRawDataRequests(
	requestID int64,
	externalID int64,
	dataSourceID int64,
	calldata []byte,
) error

func (*BandDB) AddRequest

func (b *BandDB) AddRequest(
	id int64,
	oracleScriptID int64,
	calldata []byte,
	sufficientValidatorCount int64,
	expirationHeight int64,
	resolveStatus string,
	requester string,
	txHash []byte,
	result []byte,
) error

func (*BandDB) AddRequestedValidator

func (b *BandDB) AddRequestedValidator(
	requestID int64,
	validatorAddress string,
) error

func (*BandDB) AddTransaction

func (b *BandDB) AddTransaction(
	txHash []byte,
	timestamp time.Time,
	gasUsed int64,
	gasLimit uint64,
	gasFee sdk.Coins,
	sender sdk.AccAddress,
	success bool,
	blockHeight int64,
) error

func (*BandDB) AddValidatorUpTime

func (b *BandDB) AddValidatorUpTime(
	rawConsensusAddress common.HexBytes,
	height int64,
	voted bool,
) error

func (*BandDB) BeginTransaction

func (b *BandDB) BeginTransaction()

func (*BandDB) ClearOldVotes

func (b *BandDB) ClearOldVotes(currentHeight int64) error

func (*BandDB) Commit

func (b *BandDB) Commit()

func (*BandDB) DecreaseAccountBalance

func (b *BandDB) DecreaseAccountBalance(
	address sdk.AccAddress, balance sdk.Coins, blockHeight int64,
) error

func (*BandDB) GetInvolvedAccountsFromTransferEvents

func (b *BandDB) GetInvolvedAccountsFromTransferEvents(logs sdk.ABCIMessageLogs) []sdk.AccAddress

func (*BandDB) GetInvolvedAccountsFromTx

func (b *BandDB) GetInvolvedAccountsFromTx(tx auth.StdTx) []sdk.AccAddress

func (*BandDB) GetLastProcessedHeight

func (b *BandDB) GetLastProcessedHeight() (int64, error)

func (*BandDB) GetMetadataValue

func (b *BandDB) GetMetadataValue(key string) (string, error)

func (*BandDB) GetMetadataValueInt64

func (b *BandDB) GetMetadataValueInt64(key string) (int64, error)

func (*BandDB) GetUptimeLookBackDuration

func (b *BandDB) GetUptimeLookBackDuration() (int64, error)

func (*BandDB) GetValidator

func (b *BandDB) GetValidator(validator sdk.ValAddress) (Validator, bool)

func (*BandDB) HandleMessage

func (b *BandDB) HandleMessage(txHash []byte, msg sdk.Msg, events map[string]string) (map[string]interface{}, error)

func (*BandDB) HandleTransaction

func (b *BandDB) HandleTransaction(tx auth.StdTx, txHash []byte, logs sdk.ABCIMessageLogs)

func (*BandDB) RollBack

func (b *BandDB) RollBack()

func (*BandDB) SaveChainID

func (b *BandDB) SaveChainID(chainID string) error

func (*BandDB) SetAccountBalance

func (b *BandDB) SetAccountBalance(
	address sdk.AccAddress, balance sdk.Coins, blockHeight int64,
) error

func (*BandDB) SetContext

func (b *BandDB) SetContext(ctx sdk.Context)

func (*BandDB) SetLastProcessedHeight

func (b *BandDB) SetLastProcessedHeight(height int64) error

func (*BandDB) SetMetadataValue

func (b *BandDB) SetMetadataValue(key, value string) error

func (*BandDB) SetMetadataValueInt64

func (b *BandDB) SetMetadataValueInt64(key string, value int64) error

func (*BandDB) SetUptimeLookBackDuration

func (b *BandDB) SetUptimeLookBackDuration(duration int64) error

func (*BandDB) UpdateTransaction

func (b *BandDB) UpdateTransaction(
	txHash []byte,
	messages []map[string]interface{},
) error

func (*BandDB) ValidateChainID

func (b *BandDB) ValidateChainID(chainID string) error

type Block

type Block struct {
	Height    int64  `gorm:"primary_key;auto_increment:false"`
	Timestamp int64  `gorm:"not null"`
	Proposer  string `gorm:"not null"`
	BlockHash []byte `gorm:"not null"`
}

type DataSource

type DataSource struct {
	ID          int64  `gorm:"primary_key;auto_increment:false"`
	Name        string `gorm:"not null"`
	Description string `gorm:"not null"`
	Owner       string `gorm:"not null"`
	Executable  []byte `gorm:"not null"`
	Fee         string `gorm:"not null"`
	LastUpdated int64  `gorm:"not null"`
}

type DataSourceRevision

type DataSourceRevision struct {
	DataSourceID   int64  `gorm:"primary_key;auto_increment:false"`
	RevisionNumber int64  `gorm:"primary_key"`
	Name           string `gorm:"not null"`
	Timestamp      int64  `gorm:"not null"`
	BlockHeight    int64  `gorm:"not null"`
	TxHash         []byte `sql:"default:null"`
}

type Metadata

type Metadata struct {
	Key   string `gorm:"primary_key"`
	Value string `gorm:"not null"`
}

type OracleScript

type OracleScript struct {
	ID          int64  `gorm:"primary_key;auto_increment:false"`
	Name        string `gorm:"not null"`
	Description string `gorm:"not null"`
	Owner       string `gorm:"not null"`
	CodeHash    []byte `gorm:"not null"`
	LastUpdated int64  `gorm:"not null"`
}

type OracleScriptCode

type OracleScriptCode struct {
	CodeHash []byte         `gorm:"primary_key"`
	CodeText sql.NullString `sql:"default:null"`
	Schema   sql.NullString `sql:"default:null"`
}

type OracleScriptRevision

type OracleScriptRevision struct {
	OracleScriptID int64  `gorm:"primary_key;auto_increment:false"`
	RevisionNumber int64  `gorm:"primary_key"`
	Name           string `gorm:"not null"`
	Timestamp      int64  `gorm:"not null"`
	BlockHeight    int64  `gorm:"not null"`
	TxHash         []byte `sql:"default:null"`
}

type RawDataRequests

type RawDataRequests struct {
	RequestID    int64  `gorm:"primary_key;auto_increment:false"`
	ExternalID   int64  `gorm:"primary_key;auto_increment:false"`
	DataSourceID int64  `gorm:"not null"`
	Calldata     []byte `gorm:"not null"`
}

type RelatedDataSources

type RelatedDataSources struct {
	DataSourceID   int64 `gorm:"primary_key;auto_increment:false"`
	OracleScriptID int64 `gorm:"primary_key;auto_increment:false"`
}

type Report

type Report struct {
	RequestID int64  `gorm:"primary_key;auto_increment:false"`
	Validator string `gorm:"primary_key"`
	TxHash    []byte `gorm:"not null"`
	Reporter  string `gorm:"not null"`
}

type ReportDetail

type ReportDetail struct {
	RequestID    int64  `gorm:"primary_key;auto_increment:false"`
	Validator    string `gorm:"primary_key"`
	ExternalID   int64  `gorm:"primary_key;auto_increment:false"`
	DataSourceID int64  `gorm:"not null"`
	Data         []byte `gorm:"not null"`
	Exitcode     uint8  `gorm:"not null"`
}

type Request

type Request struct {
	ID                       int64  `gorm:"primary_key;auto_increment:false"`
	OracleScriptID           int64  `gorm:"not null"`
	Calldata                 []byte `gorm:"not null"`
	SufficientValidatorCount int64  `gorm:"not null"`
	ExpirationHeight         int64  `gorm:"not null"`
	ResolveStatus            string `gorm:"not null"`
	Requester                string `gorm:"not null"`
	TxHash                   []byte `gorm:"not null"`
	Result                   []byte `sql:"default:null"`
}

type RequestedValidator

type RequestedValidator struct {
	RequestID        int64  `gorm:"primary_key;auto_increment:false"`
	ValidatorAddress string `gorm:"primary_key"`
}

type Transaction

type Transaction struct {
	TxHash      []byte          `gorm:"primary_key"`
	Timestamp   int64           `gorm:"not null"`
	GasUsed     int64           `gorm:"not null"`
	GasLimit    uint64          `gorm:"not null"`
	GasFee      string          `gorm:"not null"`
	Sender      string          `gorm:"not null"`
	Success     bool            `gorm:"not null"`
	BlockHeight int64           `gorm:"not null"`
	Messages    json.RawMessage `sql:"json;not null"`
}

type Validator

type Validator struct {
	OperatorAddress     string `gorm:"primary_key"`
	ConsensusAddress    string `gorm:"unique;not null"`
	ElectedCount        uint   `gorm:"not null"`
	VotedCount          uint   `gorm:"not null"`
	MissedCount         uint   `gorm:"not null"`
	Moniker             string `gorm:"not null"`
	Identity            string `gorm:"not null"`
	Website             string `gorm:"not null"`
	Details             string `gorm:"not null"`
	CommissionRate      string `gorm:"not null"`
	CommissionMaxRate   string `gorm:"not null"`
	CommissionMaxChange string `gorm:"not null"`
	MinSelfDelegation   string `gorm:"not null"`
	SelfDelegation      string `gorm:"not null"`
}

type ValidatorVote

type ValidatorVote struct {
	ConsensusAddress string `gorm:"primary_key"`
	BlockHeight      int64  `gorm:"primary_key;auto_increment:false"`
	Voted            bool   `gorm:"not null"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL