Documentation
¶
Overview ¶
Package kvstore
@author: xwc1125
Package kvstore ¶
@author: xwc1125
Package kvstore ¶
@author: xwc1125
Package kvstore ¶
@author: xwc1125
Package kvstore ¶
@author: xwc1125
Package kvstore ¶
@author: xwc1125
Index ¶
- Constants
- func DeleteBlock(db ChainDbDeleter, hash types.Hash, number uint64)
- func DeleteBody(db ChainDbDeleter, hash types.Hash, number uint64)
- func DeleteCanonicalHash(db ChainDbDeleter, number uint64)
- func DeleteHeader(db ChainDbDeleter, hash types.Hash, number uint64)
- func HasBody(db ChainDbReader, hash types.Hash, number uint64) bool
- func HasHeader(db ChainDbReader, hash types.Hash, number uint64) bool
- func NewKvStore(rootCtx context.Context, opts ...option) (protocol.Database, error)
- func ReadBlock(db ChainDbReader, hash types.Hash, number uint64) *models.Block
- func ReadBody(db ChainDbReader, hash types.Hash, number uint64) *models.Body
- func ReadBodyRLP(db ChainDbReader, hash types.Hash, number uint64) rlp.RawValue
- func ReadCanonicalHash(db ChainDbReader, number uint64) types.Hash
- func ReadChainConfigByHash(db ChainDbReader, bHash types.Hash) (*models.ChainConfig, error)
- func ReadChainConfigByHeight(db ChainDbReader, height uint64) (*models.ChainConfig, error)
- func ReadChainConfigLatest(db ChainDbReader) (*models.ChainConfig, error)
- func ReadHeadBlockHash(db ChainDbReader) types.Hash
- func ReadHeadHeaderHash(db ChainDbReader) types.Hash
- func ReadHeader(db ChainDbReader, hash types.Hash, number uint64) *models.Header
- func ReadHeaderNumber(db ChainDbReader, hash types.Hash) *uint64
- func ReadHeaderRLP(db ChainDbReader, hash types.Hash, number uint64) rlp.RawValue
- func ReadReceipts(db ChainDbReader, hash types.Hash, number uint64) statetype.Receipts
- func ReadTransaction(db ChainDbReader, hash types.Hash) (models.Transaction, types.Hash, uint64, uint64)
- func ReadTxLookupEntry(db ChainDbReader, hash types.Hash) (blockHash types.Hash, blockIndex uint64, txType types.TxType, txIndex uint64)
- func WithDB(db kvstore.Database) option
- func WriteBlock(db ChainDbWriter, block *models.Block)
- func WriteBody(db ChainDbWriter, hash types.Hash, number uint64, body *models.Body)
- func WriteBodyRLP(db ChainDbWriter, hash types.Hash, number uint64, rlp rlp.RawValue)
- func WriteCanonicalHash(db ChainDbWriter, hash types.Hash, number uint64)
- func WriteChainConfig(db ChainDbWriter, bHash types.Hash, height uint64, cfg *models.ChainConfig) error
- func WriteHeadBlockHash(db ChainDbWriter, hash types.Hash)
- func WriteHeadHeaderHash(db ChainDbWriter, hash types.Hash)
- func WriteHeader(db ChainDbWriter, header *models.Header)
- func WriteReceipts(db ChainDbWriter, hash types.Hash, number uint64, receipts statetype.Receipts)
- func WriteTxLookupEntries(db ChainDbWriter, block *models.Block)
- type ChainDbDeleter
- type ChainDbReader
- type ChainDbWriter
- type TxLookupEntry
Constants ¶
const ( DefaultTxStorePath = "txdata" DefaultBlockStorePath = "chaindata" DefaultCrudStorePath = "cruddata" )
Variables ¶
This section is empty.
Functions ¶
func DeleteBlock ¶
func DeleteBlock(db ChainDbDeleter, hash types.Hash, number uint64)
DeleteBlock removes all block data associated with a hash.
func DeleteBody ¶
func DeleteBody(db ChainDbDeleter, hash types.Hash, number uint64)
DeleteBody removes all block body data associated with a hash.
func DeleteCanonicalHash ¶
func DeleteCanonicalHash(db ChainDbDeleter, number uint64)
DeleteCanonicalHash 移除区块高度到hash的键值映射。
func DeleteHeader ¶
func DeleteHeader(db ChainDbDeleter, hash types.Hash, number uint64)
DeleteHeader removes all block header data associated with a hash.
func HasBody ¶
func HasBody(db ChainDbReader, hash types.Hash, number uint64) bool
HasBody verifies the existence of a block body corresponding to the hash.
func HasHeader ¶
func HasHeader(db ChainDbReader, hash types.Hash, number uint64) bool
HasHeader 检查区块头是否存在
func NewKvStore ¶
func ReadBlock ¶
ReadBlock retrieves an entire block corresponding to the hash, assembling it back from the stored header and body. If either the header or body could not be retrieved nil is returned.
Note, due to concurrent download of header and block body the header and thus canonical hash can be stored in the database but the body data not (yet).
func ReadBodyRLP ¶
ReadBodyRLP retrieves the block body (transactions and uncles) in RLP encoding.
func ReadCanonicalHash ¶
func ReadCanonicalHash(db ChainDbReader, number uint64) types.Hash
ReadCanonicalHash 读取规范区块头hash
func ReadChainConfigByHash ¶
func ReadChainConfigByHash(db ChainDbReader, bHash types.Hash) (*models.ChainConfig, error)
ReadChainConfigByHash 读取区块链配置,hash为创世区块hash
func ReadChainConfigByHeight ¶
func ReadChainConfigByHeight(db ChainDbReader, height uint64) (*models.ChainConfig, error)
func ReadChainConfigLatest ¶
func ReadChainConfigLatest(db ChainDbReader) (*models.ChainConfig, error)
ReadChainConfigLatest 读取最新的区块链配置
func ReadHeadBlockHash ¶
func ReadHeadBlockHash(db ChainDbReader) types.Hash
ReadHeadBlockHash 读取当前区块hash
func ReadHeadHeaderHash ¶
func ReadHeadHeaderHash(db ChainDbReader) types.Hash
ReadHeadHeaderHash 读取当前区块头hash
func ReadHeader ¶
ReadHeader 读取header
func ReadHeaderNumber ¶
func ReadHeaderNumber(db ChainDbReader, hash types.Hash) *uint64
ReadHeaderNumber 根据区块hash检索区块高度值
func ReadHeaderRLP ¶
ReadHeaderRLP retrieves a block header in its raw RLP database encoding.
func ReadReceipts ¶
ReadReceipts retrieves all the transaction receipts belonging to a block.
func ReadTransaction ¶
func ReadTransaction(db ChainDbReader, hash types.Hash) (models.Transaction, types.Hash, uint64, uint64)
ReadTransaction retrieves a specific transaction from the database, along with its added positional metadata.
func ReadTxLookupEntry ¶
func ReadTxLookupEntry(db ChainDbReader, hash types.Hash) (blockHash types.Hash, blockIndex uint64, txType types.TxType, txIndex uint64)
ReadTxLookupEntry retrieves the positional metadata associated with a transaction hash to allow retrieving the transaction or receipt by hash.
func WriteBlock ¶
func WriteBlock(db ChainDbWriter, block *models.Block)
WriteBlock serializes a block into the database, header and body separately.
func WriteBodyRLP ¶
WriteBodyRLP stores an RLP encoded block body into the database.
func WriteCanonicalHash ¶
func WriteCanonicalHash(db ChainDbWriter, hash types.Hash, number uint64)
WriteCanonicalHash 写入规范区块头hash。
func WriteChainConfig ¶
func WriteChainConfig(db ChainDbWriter, bHash types.Hash, height uint64, cfg *models.ChainConfig) error
WriteChainConfig 写入链配置
func WriteHeadBlockHash ¶
func WriteHeadBlockHash(db ChainDbWriter, hash types.Hash)
WriteHeadBlockHash 写入当前区块hash
func WriteHeadHeaderHash ¶
func WriteHeadHeaderHash(db ChainDbWriter, hash types.Hash)
WriteHeadHeaderHash 写入当前区块头hash
func WriteReceipts ¶
WriteReceipts stores all the transaction receipts belonging to a block.
func WriteTxLookupEntries ¶
func WriteTxLookupEntries(db ChainDbWriter, block *models.Block)
WriteTxLookupEntries stores a positional metadata for every transaction from a block, enabling hash based transaction and receipt lookups.
Types ¶
type ChainDbDeleter ¶
ChainDbDeleter wraps the Delete method of a backing data store.
type ChainDbReader ¶
ChainDbReader wraps the Has and Get method of a backing data store.
type ChainDbWriter ¶
ChainDbWriter wraps the Put method of a backing data store.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package block_store
|
Package block_store |
|
Package crud_store
|
Package crud_store |
|
Package tx_store
|
Package tx_store |
