Documentation
¶
Index ¶
- type Config
- type KeyPool
- type Metrics
- type ShardingConfig
- type ShardingMetadata
- type ShardingStore
- func (store *ShardingStore) Close() error
- func (store *ShardingStore) EarlistBlockNumber() (uint64, bool)
- func (store *ShardingStore) GetBlock(bhon types.BlockHashOrNumber, isFull bool) (types.Lazy[*ethTypes.Block], error)
- func (store *ShardingStore) GetBlockNumber(bhon types.BlockHashOrNumber) (uint64, bool, error)
- func (store *ShardingStore) GetBlockReceipts(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.Receipt], error)
- func (store *ShardingStore) GetBlockTraces(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.LocalizedTrace], error)
- func (store *ShardingStore) GetBlockTransactionCount(bhon types.BlockHashOrNumber) (int64, error)
- func (store *ShardingStore) GetTrace(txHash common.Hash, index uint) (*ethTypes.LocalizedTrace, error)
- func (store *ShardingStore) GetTransactionByHash(txHash common.Hash) (*ethTypes.TransactionDetail, error)
- func (store *ShardingStore) GetTransactionByIndex(bhon types.BlockHashOrNumber, txIndex uint32) (*ethTypes.TransactionDetail, error)
- func (store *ShardingStore) GetTransactionReceipt(txHash common.Hash) (*ethTypes.Receipt, error)
- func (store *ShardingStore) GetTransactionTraces(txHash common.Hash) ([]ethTypes.LocalizedTrace, error)
- func (store *ShardingStore) NextBlockNumber() uint64
- func (store *ShardingStore) Write(data ...evm.BlockData) error
- type Store
- func (store *Store) Close() error
- func (store *Store) EarlistBlockNumber() (uint64, bool)
- func (store *Store) GetBlock(bhon types.BlockHashOrNumber, isFull bool) (types.Lazy[*ethTypes.Block], error)
- func (store *Store) GetBlockNumber(bhon types.BlockHashOrNumber) (uint64, bool, error)
- func (store *Store) GetBlockReceipts(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.Receipt], error)
- func (store *Store) GetBlockTraces(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.LocalizedTrace], error)
- func (store *Store) GetBlockTransactionCount(bhon types.BlockHashOrNumber) (int64, error)
- func (store *Store) GetTrace(txHash common.Hash, index uint) (*ethTypes.LocalizedTrace, error)
- func (store *Store) GetTransactionByHash(txHash common.Hash) (*ethTypes.TransactionDetail, error)
- func (store *Store) GetTransactionByIndex(bhon types.BlockHashOrNumber, txIndex uint32) (*ethTypes.TransactionDetail, error)
- func (store *Store) GetTransactionReceipt(txHash common.Hash) (*ethTypes.Receipt, error)
- func (store *Store) GetTransactionTraces(txHash common.Hash) ([]ethTypes.LocalizedTrace, error)
- func (store *Store) NextBlockNumber() uint64
- func (store *Store) Write(data ...evm.BlockData) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// LevelDB database path.
Path string `default:"db"`
// DefaultNextBlockNumber is the block number to write next block if database is empty.
DefaultNextBlockNumber uint64
}
Config holds the configurations for LevelDB database.
func DefaultConfig ¶
func DefaultConfig() (config Config)
type KeyPool ¶
KeyPool is used to pool LevelDB database key for memory saving.
func NewKeyPool ¶
NewKeyPool creats a new key pool with given prefix and key size.
type ShardingConfig ¶
type ShardingMetadata ¶
type ShardingMetadata struct {
BlocksPerShard uint64
EarlistShard uint64 // inclusive, starts from 1, 0 indicates unavailable
LatestShard uint64 // inclusive, starts from 1, 0 indicates unavailable
}
func (*ShardingMetadata) Validate ¶
func (metadata *ShardingMetadata) Validate(shardingBlocks uint64) error
type ShardingStore ¶
type ShardingStore struct {
// contains filtered or unexported fields
}
ShardingStore stores blockchain data in a sharding manner based on block number range.
func NewShardingStore ¶
func NewShardingStore(config ShardingConfig) (*ShardingStore, error)
NewShardingStore open or create a sharding store for the given path.
func (*ShardingStore) Close ¶
func (store *ShardingStore) Close() error
Close closes the underlying LevelDB databases.
func (*ShardingStore) EarlistBlockNumber ¶
func (store *ShardingStore) EarlistBlockNumber() (uint64, bool)
EarlistBlockNumber returns the earlist block number in database if any.
func (*ShardingStore) GetBlock ¶
func (store *ShardingStore) GetBlock(bhon types.BlockHashOrNumber, isFull bool) (types.Lazy[*ethTypes.Block], error)
func (*ShardingStore) GetBlockNumber ¶
func (store *ShardingStore) GetBlockNumber(bhon types.BlockHashOrNumber) (uint64, bool, error)
func (*ShardingStore) GetBlockReceipts ¶
func (store *ShardingStore) GetBlockReceipts(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.Receipt], error)
func (*ShardingStore) GetBlockTraces ¶
func (store *ShardingStore) GetBlockTraces(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.LocalizedTrace], error)
func (*ShardingStore) GetBlockTransactionCount ¶
func (store *ShardingStore) GetBlockTransactionCount(bhon types.BlockHashOrNumber) (int64, error)
func (*ShardingStore) GetTrace ¶
func (store *ShardingStore) GetTrace(txHash common.Hash, index uint) (*ethTypes.LocalizedTrace, error)
func (*ShardingStore) GetTransactionByHash ¶
func (store *ShardingStore) GetTransactionByHash(txHash common.Hash) (*ethTypes.TransactionDetail, error)
func (*ShardingStore) GetTransactionByIndex ¶
func (store *ShardingStore) GetTransactionByIndex(bhon types.BlockHashOrNumber, txIndex uint32) (*ethTypes.TransactionDetail, error)
func (*ShardingStore) GetTransactionReceipt ¶
func (*ShardingStore) GetTransactionTraces ¶
func (store *ShardingStore) GetTransactionTraces(txHash common.Hash) ([]ethTypes.LocalizedTrace, error)
func (*ShardingStore) NextBlockNumber ¶
func (store *ShardingStore) NextBlockNumber() uint64
NextBlockNumber returns the next block number to write in sequence.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides operations on a LevelDB database.
func NewStore ¶
NewStore opens or creates a DB for the given path.
If corruption detected for an existing DB, it will try to recover the DB.
If the DB of specified path is empty and defaultNextBlockNumber specified, store will write data from defaultNextBlockNumber.
func (*Store) EarlistBlockNumber ¶
EarlistBlockNumber returns the earlist block number in database if any.
func (*Store) GetBlock ¶
func (store *Store) GetBlock(bhon types.BlockHashOrNumber, isFull bool) (types.Lazy[*ethTypes.Block], error)
GetBlock returns block for the given block hash or number. If not found, returns nil.
func (*Store) GetBlockNumber ¶
GetBlockNumber returns block number for the given block hash or number if any.
func (*Store) GetBlockReceipts ¶
func (store *Store) GetBlockReceipts(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.Receipt], error)
GetBlockReceipts returns all block receipts for the given block hash or number. If not found, returns nil.
func (*Store) GetBlockTraces ¶
func (store *Store) GetBlockTraces(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.LocalizedTrace], error)
GetBlockTraces returns all block traces for the given block hash or number. If not found, returns nil.
func (*Store) GetBlockTransactionCount ¶
func (store *Store) GetBlockTransactionCount(bhon types.BlockHashOrNumber) (int64, error)
GetBlockTransactionCount returns the transaction count for the given block hash or number. Returns -1 if the given block hash not found.
func (*Store) GetTrace ¶
GetTrace returns single trace for the given transaction hash at specified index. If not found, returns nil.
func (*Store) GetTransactionByHash ¶
GetTransactionByHash returns transaction for the given transaction hash. If not found, returns nil.
func (*Store) GetTransactionByIndex ¶
func (store *Store) GetTransactionByIndex(bhon types.BlockHashOrNumber, txIndex uint32) (*ethTypes.TransactionDetail, error)
GetTransactionByIndex returns transaction for the given block hash or number along with transaction index. If not found, returns nil.
func (*Store) GetTransactionReceipt ¶
GetTransactionReceipt returns receipt for the given transaction hash. If not found, returns nil.
func (*Store) GetTransactionTraces ¶
GetTransactionTraces returns all transaction traces for the given transaction hash. If not found, returns nil.
func (*Store) NextBlockNumber ¶
NextBlockNumber returns the next block number to write in sequence.