Documentation ¶
Overview ¶
Package base contains the base sql implementation
nolint:dupl,golint,revive,stylecheck
Index ¶
- Variables
- func GetAllModels() (allModels []interface{})
- type BlockTime
- type EthTx
- type LastBlockTime
- type LastConfirmedBlockInfo
- type LastIndexedInfo
- type Log
- type Receipt
- type Store
- func (s Store) ConfirmEthTxsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
- func (s Store) ConfirmEthTxsInRange(ctx context.Context, startBlock, endBlock uint64, chainID uint32) error
- func (s Store) ConfirmLogsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
- func (s Store) ConfirmLogsInRange(ctx context.Context, startBlock, endBlock uint64, chainID uint32) error
- func (s Store) ConfirmReceiptsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
- func (s Store) ConfirmReceiptsInRange(ctx context.Context, startBlock, endBlock uint64, chainID uint32) error
- func (s Store) DB() *gorm.DB
- func (s Store) DeleteEthTxsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
- func (s Store) DeleteLogsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
- func (s Store) DeleteReceiptsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
- func (s Store) RetrieveBlockTime(ctx context.Context, chainID uint32, blockNumber uint64) (uint64, error)
- func (s Store) RetrieveEthTxsInRange(ctx context.Context, ethTxFilter db.EthTxFilter, startBlock, endBlock uint64, ...) ([]types.Transaction, error)
- func (s Store) RetrieveEthTxsWithFilter(ctx context.Context, ethTxFilter db.EthTxFilter, page int) ([]types.Transaction, error)
- func (s Store) RetrieveLastBlockTime(ctx context.Context, chainID uint32) (uint64, error)
- func (s Store) RetrieveLastConfirmedBlock(ctx context.Context, chainID uint32) (uint64, error)
- func (s Store) RetrieveLastIndexed(ctx context.Context, contractAddress common.Address, chainID uint32) (uint64, error)
- func (s Store) RetrieveLogsInRange(ctx context.Context, logFilter db.LogFilter, startBlock, endBlock uint64, ...) (logs []*types.Log, err error)
- func (s Store) RetrieveLogsWithFilter(ctx context.Context, logFilter db.LogFilter, page int) (logs []*types.Log, err error)
- func (s Store) RetrieveReceiptsInRange(ctx context.Context, receiptFilter db.ReceiptFilter, ...) (receipts []types.Receipt, err error)
- func (s Store) RetrieveReceiptsWithFilter(ctx context.Context, receiptFilter db.ReceiptFilter, page int) (receipts []types.Receipt, err error)
- func (s Store) StoreBlockTime(ctx context.Context, chainID uint32, blockNumber, timestamp uint64) error
- func (s Store) StoreEthTx(ctx context.Context, tx *types.Transaction, chainID uint32, ...) error
- func (s Store) StoreLastBlockTime(ctx context.Context, chainID uint32, blockNumber uint64) error
- func (s Store) StoreLastConfirmedBlock(ctx context.Context, chainID uint32, blockNumber uint64) error
- func (s Store) StoreLastIndexed(ctx context.Context, contractAddress common.Address, chainID uint32, ...) error
- func (s Store) StoreLog(ctx context.Context, log types.Log, chainID uint32) error
- func (s Store) StoreReceipt(ctx context.Context, receipt types.Receipt, chainID uint32) error
Constants ¶
This section is empty.
Variables ¶
var ( // TxHashFieldName is the field name of the tx hash. TxHashFieldName string // ChainIDFieldName gets the chain id field name. ChainIDFieldName string // BlockNumberFieldName is the name of the block number field. BlockNumberFieldName string // ContractAddressFieldName is the address of the contract. ContractAddressFieldName string // BlockIndexFieldName is the index field name. BlockIndexFieldName string // BlockHashFieldName is the block hash field name. BlockHashFieldName string // ConfirmedFieldName is the confirmed field name. ConfirmedFieldName string )
var PageSize = 100
PageSize is the amount of entries per page of logs.
Functions ¶
func GetAllModels ¶
func GetAllModels() (allModels []interface{})
GetAllModels gets all models to migrate see: https://medium.com/@SaifAbid/slice-interfaces-8c78f8b6345d for an explanation of why we can't do this at initialization time
Types ¶
type BlockTime ¶ added in v0.0.27
type BlockTime struct { // ChainID is the chain id of the contract ChainID uint32 `gorm:"column:chain_id;primaryKey;auto_increment:false"` // BlockNumber is the block number BlockNumber uint64 `gorm:"column:block_number;primaryKey;auto_increment:false"` // Timestamp is the timestamp of the block Timestamp uint64 `gorm:"column:timestamp;auto_increment:false"` }
BlockTime contains the timestamp of a block.
type EthTx ¶
type EthTx struct { // TxHash is the hash of the transaction TxHash string `gorm:"column:tx_hash;primaryKey"` // ChainID is the chain id of the transaction ChainID uint32 `gorm:"column:chain_id;primaryKey;auto_increment:false"` // BlockHash is the hash of the block in which the transaction was included BlockHash string `gorm:"block_hash"` // BlockNumber is the block in which the transaction was included BlockNumber uint64 `gorm:"column:block_number"` // RawTx is the raw serialized transaction RawTx []byte `gorm:"column:raw_tx"` // GasFeeCap contains the gas fee cap stored in wei GasFeeCap uint64 // GasTipCap contains the gas tip cap stored in wei GasTipCap uint64 // Confirmed is true if this log has been confirmed by the chain Confirmed bool `gorm:"confirmed"` }
EthTx contains a processed ethereum transaction.
type LastBlockTime ¶ added in v0.0.27
type LastBlockTime struct { gorm.Model // ChainID is the chain id of the contract ChainID uint32 `gorm:"column:chain_id;primaryKey;auto_increment:false"` // BlockNumber is the block number BlockNumber uint64 `gorm:"column:block_number;auto_increment:false"` }
LastBlockTime contains the last block that had its timestamp stored.
type LastConfirmedBlockInfo ¶ added in v0.0.16
type LastConfirmedBlockInfo struct { gorm.Model // ChainID is the chain id of the contract ChainID uint32 `gorm:"column:chain_id"` // BlockNumber is the last block number indexed BlockNumber uint64 `gorm:"column:block_number;auto_increment:false"` }
LastConfirmedBlockInfo contains information on when a chain last had a block pass the required confirmation threshold and was validated.
type LastIndexedInfo ¶
type LastIndexedInfo struct { gorm.Model // ContractAddress is the contract address ContractAddress string `gorm:"column:contract_address;index:idx_last_indexed,priority:1"` // BlockNumber is the last block number indexed BlockNumber uint64 `gorm:"column:block_number;auto_increment:false;index:idx_last_indexed,priority:2"` // ChainID is the chain id of the contract ChainID uint32 `gorm:"column:chain_id"` }
LastIndexedInfo contains information on when a contract was last indexed.
type Log ¶
type Log struct { // ContractAddress is the address of the contract that generated the event ContractAddress string `gorm:"column:contract_address;primaryKey"` // ChainID is the chain id of the contract that generated the event ChainID uint32 `gorm:"column:chain_id;primaryKey;auto_increment:false"` // PrimaryTopic is the primary topic of the event. Topics[0] PrimaryTopic sql.NullString `gorm:"primary_topic"` // TopicA is the first topic. Topics[1] TopicA sql.NullString `gorm:"topic_a"` // TopicB is the second topic. Topics[2] TopicB sql.NullString `gorm:"topic_b"` // TopicC is the third topic. Topics[3] TopicC sql.NullString `gorm:"topic_c"` // Data is the data provided by the contract Data []byte `gorm:"data"` // BlockNumber is the block in which the transaction was included BlockNumber uint64 `gorm:"column:block_number"` // TxHash is the hash of the transaction TxHash string `gorm:"column:tx_hash;primaryKey"` // TxIndex is the index of the transaction in the block TxIndex uint64 `gorm:"tx_index"` // BlockHash is the hash of the block in which the transaction was included BlockHash string `gorm:"block_hash"` // Index is the index of the log in the block BlockIndex uint64 `gorm:"column:block_index;primaryKey;auto_increment:false"` // Removed is true if this log was reverted due to a chain re-organization Removed bool `gorm:"removed"` // Confirmed is true if this log has been confirmed by the chain Confirmed bool `gorm:"confirmed"` }
Log stores the log of an event.
type Receipt ¶
type Receipt struct { // ChainID is the chain id of the receipt ChainID uint32 `gorm:"column:chain_id;primaryKey;auto_increment:false"` // Type is the type Type uint8 `gorm:"receipt_type"` // PostState is the post state PostState []byte `gorm:"post_state"` // Status is the status of the transaction Status uint64 `gorm:"status"` // CumulativeGasUsed is the total amount of gas used when this transaction was executed in the block CumulativeGasUsed uint64 `gorm:"cumulative_gas_used"` // Bloom is the bloom filter Bloom []byte `gorm:"bloom"` // TxHash is the hash of the transaction TxHash string `gorm:"column:tx_hash;primaryKey"` // ContractAddress is the address of the contract ContractAddress string `gorm:"column:contract_address"` // GasUsed is the amount of gas used by this transaction alone GasUsed uint64 `gorm:"gas_used"` // BlockHash is the hash of the block in which this transaction was included BlockHash string `gorm:"block_hash"` // BlockNumber is the block in which this transaction was included BlockNumber uint64 `gorm:"block_number"` // TransactionIndex is the index of the transaction in the block TransactionIndex uint64 `gorm:"transaction_index"` // Confirmed is true if this log has been confirmed by the chain Confirmed bool `gorm:"confirmed"` }
Receipt stores the receipt of a transaction.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the sqlite store. It extends the base store for sqlite specific queries.
func (Store) ConfirmEthTxsForBlockHash ¶ added in v0.0.16
func (s Store) ConfirmEthTxsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
ConfirmEthTxsForBlockHash confirms eth txs for a given block hash.
func (Store) ConfirmEthTxsInRange ¶ added in v0.0.16
func (s Store) ConfirmEthTxsInRange(ctx context.Context, startBlock, endBlock uint64, chainID uint32) error
ConfirmEthTxsInRange confirms eth txs in a range.
func (Store) ConfirmLogsForBlockHash ¶ added in v0.0.16
func (s Store) ConfirmLogsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
ConfirmLogsForBlockHash confirms logs for a given block hash.
func (Store) ConfirmLogsInRange ¶ added in v0.0.16
func (s Store) ConfirmLogsInRange(ctx context.Context, startBlock, endBlock uint64, chainID uint32) error
ConfirmLogsInRange confirms logs in a range.
func (Store) ConfirmReceiptsForBlockHash ¶ added in v0.0.16
func (s Store) ConfirmReceiptsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
ConfirmReceiptsForBlockHash confirms receipts for a given block hash.
func (Store) ConfirmReceiptsInRange ¶ added in v0.0.16
func (s Store) ConfirmReceiptsInRange(ctx context.Context, startBlock, endBlock uint64, chainID uint32) error
ConfirmReceiptsInRange confirms receipts in a range.
func (Store) DeleteEthTxsForBlockHash ¶ added in v0.0.16
func (s Store) DeleteEthTxsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
DeleteEthTxsForBlockHash deletes eth txs with a given block hash.
func (Store) DeleteLogsForBlockHash ¶ added in v0.0.16
func (s Store) DeleteLogsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
DeleteLogsForBlockHash deletes logs with a given block hash.
func (Store) DeleteReceiptsForBlockHash ¶ added in v0.0.16
func (s Store) DeleteReceiptsForBlockHash(ctx context.Context, blockHash common.Hash, chainID uint32) error
DeleteReceiptsForBlockHash deletes receipts with a given block hash.
func (Store) RetrieveBlockTime ¶ added in v0.0.27
func (s Store) RetrieveBlockTime(ctx context.Context, chainID uint32, blockNumber uint64) (uint64, error)
RetrieveBlockTime retrieves a block time for a chain and block number.
func (Store) RetrieveEthTxsInRange ¶ added in v0.0.9
func (s Store) RetrieveEthTxsInRange(ctx context.Context, ethTxFilter db.EthTxFilter, startBlock, endBlock uint64, page int) ([]types.Transaction, error)
RetrieveEthTxsInRange retrieves eth transactions that match an inputted filter and are within a range given a page.
func (Store) RetrieveEthTxsWithFilter ¶ added in v0.0.9
func (s Store) RetrieveEthTxsWithFilter(ctx context.Context, ethTxFilter db.EthTxFilter, page int) ([]types.Transaction, error)
RetrieveEthTxsWithFilter retrieves eth transactions with a filter given a page.
func (Store) RetrieveLastBlockTime ¶ added in v0.0.27
RetrieveLastBlockTime retrieves the last block time stored for a chain.
func (Store) RetrieveLastConfirmedBlock ¶ added in v0.0.16
RetrieveLastConfirmedBlock retrieves the last block number that has been confirmed.
func (Store) RetrieveLastIndexed ¶
func (s Store) RetrieveLastIndexed(ctx context.Context, contractAddress common.Address, chainID uint32) (uint64, error)
RetrieveLastIndexed retrieves the last indexed block number for a contract.
func (Store) RetrieveLogsInRange ¶ added in v0.0.9
func (s Store) RetrieveLogsInRange(ctx context.Context, logFilter db.LogFilter, startBlock, endBlock uint64, page int) (logs []*types.Log, err error)
RetrieveLogsInRange retrieves all logs that match an inputted filter and are within a range given a page.
func (Store) RetrieveLogsWithFilter ¶ added in v0.0.9
func (s Store) RetrieveLogsWithFilter(ctx context.Context, logFilter db.LogFilter, page int) (logs []*types.Log, err error)
RetrieveLogsWithFilter retrieves all logs that match a filter given a page.
func (Store) RetrieveReceiptsInRange ¶ added in v0.0.9
func (s Store) RetrieveReceiptsInRange(ctx context.Context, receiptFilter db.ReceiptFilter, startBlock, endBlock uint64, page int) (receipts []types.Receipt, err error)
RetrieveReceiptsInRange retrieves receipts that match an inputted filter and are within a range given a page.
func (Store) RetrieveReceiptsWithFilter ¶ added in v0.0.9
func (s Store) RetrieveReceiptsWithFilter(ctx context.Context, receiptFilter db.ReceiptFilter, page int) (receipts []types.Receipt, err error)
RetrieveReceiptsWithFilter retrieves receipts with a filter given a page.
func (Store) StoreBlockTime ¶ added in v0.0.27
func (s Store) StoreBlockTime(ctx context.Context, chainID uint32, blockNumber, timestamp uint64) error
StoreBlockTime stores a block time for a chain.
func (Store) StoreEthTx ¶
func (s Store) StoreEthTx(ctx context.Context, tx *types.Transaction, chainID uint32, blockHash common.Hash, blockNumber uint64) error
StoreEthTx stores a processed text.
func (Store) StoreLastBlockTime ¶ added in v0.0.27
StoreLastBlockTime stores the last block time stored for a chain. It updates the value if there is a previous last indexed value, and creates a new entry if there is no previous value. TODO: Potentially use generics since the logic is identical to that of `lastindexed.go`.
func (Store) StoreLastConfirmedBlock ¶ added in v0.0.16
func (s Store) StoreLastConfirmedBlock(ctx context.Context, chainID uint32, blockNumber uint64) error
StoreLastConfirmedBlock stores the last block number that has been confirmed. It updates the value if there is a previous last block confirmed value, and creates a new entry if there is no previous value.
func (Store) StoreLastIndexed ¶
func (s Store) StoreLastIndexed(ctx context.Context, contractAddress common.Address, chainID uint32, blockNumber uint64) error
StoreLastIndexed stores the last indexed block number for a contract. It updates the value if there is a previous last indexed value, and creates a new entry if there is no previous value.