Documentation ¶
Overview ¶
Copyright 2018 The go-ethereum Authors This file is part of the go-ethereum library.
The go-ethereum library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The go-ethereum library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 映像,链配置数据,链版本
Package rawdb contains a collection of low level database accessors.
Index ¶
- Variables
- func DeleteBlock(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
- func DeleteBody(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
- func DeleteCanonicalHash(db DatabaseDeleter, number uint64, appid ...string)
- func DeleteHeader(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
- func DeleteReceipts(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
- func DeleteTd(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
- func DeleteTxLookupEntry(db DatabaseDeleter, hash common.Hash, appid ...string)
- func FindCommonAncestor(db DatabaseReader, a, b *types.Header, appid ...string) *types.Header
- func HasBody(db DatabaseReader, hash common.Hash, number uint64, appid ...string) bool
- func HasHeader(db DatabaseReader, hash common.Hash, number uint64, appid ...string) bool
- func ReadAllChainConfig(db DatabaseReader) map[string]*params.ChainConfig
- func ReadAppId(db DatabaseReader) []string
- func ReadBlock(db DatabaseReader, hash common.Hash, number uint64, appid ...string) *types.Block
- func ReadBloomBits(db DatabaseReader, bit uint, section uint64, head common.Hash, appid ...string) ([]byte, error)
- func ReadBody(db DatabaseReader, hash common.Hash, number uint64, appid ...string) *types.Body
- func ReadBodyRLP(db DatabaseReader, hash common.Hash, number uint64, appid ...string) rlp.RawValue
- func ReadCanonicalHash(db DatabaseReader, number uint64, appid ...string) common.Hash
- func ReadChainConfig(db DatabaseReader, hash common.Hash, appid ...string) *params.ChainConfig
- func ReadDatabaseVersion(db DatabaseReader) int
- func ReadFastTrieProgress(db DatabaseReader, appid ...string) uint64
- func ReadHeadBlockHash(db DatabaseReader, appid ...string) common.Hash
- func ReadHeadFastBlockHash(db DatabaseReader, appid ...string) common.Hash
- func ReadHeadHeaderHash(db DatabaseReader, appid ...string) common.Hash
- func ReadHeader(db DatabaseReader, hash common.Hash, number uint64, appid ...string) *types.Header
- func ReadHeaderNumber(db DatabaseReader, hash common.Hash, appid ...string) *uint64
- func ReadHeaderRLP(db DatabaseReader, hash common.Hash, number uint64, appid ...string) rlp.RawValue
- func ReadPreimage(db DatabaseReader, hash common.Hash, appid ...string) []byte
- func ReadReceipt(db DatabaseReader, hash common.Hash, appid ...string) (*types.Receipt, common.Hash, uint64, uint64)
- func ReadReceipts(db DatabaseReader, hash common.Hash, number uint64, appid ...string) types.Receipts
- func ReadTd(db DatabaseReader, hash common.Hash, number uint64, appid ...string) *big.Int
- func ReadTransaction(db DatabaseReader, hash common.Hash, appid ...string) (*types.Transaction, common.Hash, uint64, uint64)
- func ReadTxLookupEntry(db DatabaseReader, hash common.Hash, appid ...string) (common.Hash, uint64, uint64)
- func WriteAppId(db DatabaseWriter, appId []string)
- func WriteBlock(db DatabaseWriter, block *types.Block, appid ...string)
- func WriteBloomBits(db DatabaseWriter, bit uint, section uint64, head common.Hash, bits []byte, ...)
- func WriteBody(db DatabaseWriter, hash common.Hash, number uint64, body *types.Body, ...)
- func WriteBodyRLP(db DatabaseWriter, hash common.Hash, number uint64, rlp rlp.RawValue, ...)
- func WriteCanonicalHash(db DatabaseWriter, hash common.Hash, number uint64, appid ...string)
- func WriteChainConfig(db DatabaseWriter, hash common.Hash, cfg map[string]*params.ChainConfig, ...)
- func WriteDatabaseVersion(db DatabaseWriter, version int)
- func WriteFastTrieProgress(db DatabaseWriter, count uint64, appid ...string)
- func WriteHeadBlockHash(db DatabaseWriter, hash common.Hash, appid ...string)
- func WriteHeadFastBlockHash(db DatabaseWriter, hash common.Hash, appid ...string)
- func WriteHeadHeaderHash(db DatabaseWriter, hash common.Hash, appid ...string)
- func WriteHeader(db DatabaseWriter, header *types.Header, appid ...string)
- func WritePreimages(db DatabaseWriter, number uint64, preimages map[common.Hash][]byte, ...)
- func WriteReceipts(db DatabaseWriter, hash common.Hash, number uint64, receipts types.Receipts, ...)
- func WriteTd(db DatabaseWriter, hash common.Hash, number uint64, td *big.Int, ...)
- func WriteTxLookupEntries(db DatabaseWriter, block *types.Block, appid ...string)
- type DatabaseDeleter
- type DatabaseReader
- type DatabaseWriter
- type TxLookupEntry
Constants ¶
This section is empty.
Variables ¶
var ( // Chain index prefixes (use `i` + single byte to avoid mixing data types). BloomBitsIndexPrefix = []byte("iB") // BloomBitsIndexPrefix is the data table of a chain indexer to track its progress )
The fields below define the low level database schema prefixing.
Functions ¶
func DeleteBlock ¶
func DeleteBlock(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
DeleteBlock removes all block data associated with a hash.
func DeleteBody ¶
func DeleteBody(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
DeleteBody removes all block body data associated with a hash.
func DeleteCanonicalHash ¶
func DeleteCanonicalHash(db DatabaseDeleter, number uint64, appid ...string)
DeleteCanonicalHash removes the number to hash canonical mapping.
func DeleteHeader ¶
func DeleteHeader(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
DeleteHeader removes all block header data associated with a hash.
func DeleteReceipts ¶
func DeleteReceipts(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
DeleteReceipts removes all receipt data associated with a block hash.
func DeleteTd ¶
func DeleteTd(db DatabaseDeleter, hash common.Hash, number uint64, appid ...string)
DeleteTd removes all block total difficulty data associated with a hash.
func DeleteTxLookupEntry ¶
func DeleteTxLookupEntry(db DatabaseDeleter, hash common.Hash, appid ...string)
DeleteTxLookupEntry removes all transaction data associated with a hash.
func FindCommonAncestor ¶
FindCommonAncestor returns the last common ancestor of two block headers
func ReadAllChainConfig ¶
func ReadAllChainConfig(db DatabaseReader) map[string]*params.ChainConfig
func ReadAppId ¶
func ReadAppId(db DatabaseReader) []string
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 ReadBloomBits ¶
func ReadBloomBits(db DatabaseReader, bit uint, section uint64, head common.Hash, appid ...string) ([]byte, error)
ReadBloomBits retrieves the compressed bloom bit vector belonging to the given section and bit index from the.
func ReadBodyRLP ¶
ReadBodyRLP retrieves the block body (transactions and uncles) in RLP encoding.
func ReadCanonicalHash ¶
func ReadCanonicalHash(db DatabaseReader, number uint64, appid ...string) common.Hash
常规 ReadCanonicalHash retrieves the hash assigned to a canonical block number.
func ReadChainConfig ¶
func ReadChainConfig(db DatabaseReader, hash common.Hash, appid ...string) *params.ChainConfig
ReadChainConfig retrieves the consensus settings based on the given genesis hash.
func ReadChainConfig(db DatabaseReader, hash common.Hash, appid ...string) *params.ChainConfig { var key = append(configPrefix, hash[:]...) if len(appid) == 1 && appid[0] != "" { key = append([]byte(appid[0]), key...) } log.Info("---读链config数据", "appid", appid[0]) data, _ := db.Get(key) if len(data) == 0 { return nil } var config params.ChainConfig if err := json.Unmarshal(data, &config); err != nil { log.Error("Invalid chain config JSON", "hash", hash, "err", err) return nil } return &config }
func ReadDatabaseVersion ¶
func ReadDatabaseVersion(db DatabaseReader) int
ReadDatabaseVersion retrieves the version number of the database.
func ReadFastTrieProgress ¶
func ReadFastTrieProgress(db DatabaseReader, appid ...string) uint64
ReadFastTrieProgress retrieves the number of tries nodes fast synced to allow reporting correct numbers across restarts.
func ReadHeadBlockHash ¶
func ReadHeadBlockHash(db DatabaseReader, appid ...string) common.Hash
ReadHeadBlockHash retrieves the hash of the current canonical head block.
func ReadHeadFastBlockHash ¶
func ReadHeadFastBlockHash(db DatabaseReader, appid ...string) common.Hash
ReadHeadFastBlockHash retrieves the hash of the current fast-sync head block.
func ReadHeadHeaderHash ¶
func ReadHeadHeaderHash(db DatabaseReader, appid ...string) common.Hash
ReadHeadHeaderHash retrieves the hash of the current canonical head header.
func ReadHeader ¶
ReadHeader retrieves the block header corresponding to the hash.
func ReadHeaderNumber ¶
func ReadHeaderNumber(db DatabaseReader, hash common.Hash, appid ...string) *uint64
ReadHeaderNumber returns the header number assigned to a hash.
func ReadHeaderRLP ¶
func ReadHeaderRLP(db DatabaseReader, hash common.Hash, number uint64, appid ...string) rlp.RawValue
ReadHeaderRLP retrieves a block header in its raw RLP database encoding.
func ReadPreimage ¶
func ReadPreimage(db DatabaseReader, hash common.Hash, appid ...string) []byte
ReadPreimage retrieves a single preimage of the provided hash.
func ReadReceipt ¶
func ReadReceipt(db DatabaseReader, hash common.Hash, appid ...string) (*types.Receipt, common.Hash, uint64, uint64)
ReadReceipt retrieves a specific transaction receipt from the database, along with its added positional metadata.
func ReadReceipts ¶
func ReadReceipts(db DatabaseReader, hash common.Hash, number uint64, appid ...string) types.Receipts
ReadReceipts retrieves all the transaction receipts belonging to a block.
func ReadTransaction ¶
func ReadTransaction(db DatabaseReader, hash common.Hash, appid ...string) (*types.Transaction, common.Hash, uint64, uint64)
ReadTransaction retrieves a specific transaction from the database, along with its added positional metadata.
func ReadTxLookupEntry ¶
func ReadTxLookupEntry(db DatabaseReader, hash common.Hash, appid ...string) (common.Hash, uint64, uint64)
ReadTxLookupEntry retrieves the positional metadata associated with a transaction hash to allow retrieving the transaction or receipt by hash.
func WriteAppId ¶
func WriteAppId(db DatabaseWriter, appId []string)
func WriteBlock ¶
func WriteBlock(db DatabaseWriter, block *types.Block, appid ...string)
WriteBlock serializes a block into the database, header and body separately.
func WriteBloomBits ¶
func WriteBloomBits(db DatabaseWriter, bit uint, section uint64, head common.Hash, bits []byte, appid ...string)
WriteBloomBits stores the compressed bloom bits vector belonging to the given section and bit index.
func WriteBody ¶
func WriteBody(db DatabaseWriter, hash common.Hash, number uint64, body *types.Body, appid ...string)
WriteBody storea a block body into the database.
func WriteBodyRLP ¶
func WriteBodyRLP(db DatabaseWriter, hash common.Hash, number uint64, rlp rlp.RawValue, appid ...string)
WriteBodyRLP stores an RLP encoded block body into the database.
func WriteCanonicalHash ¶
func WriteCanonicalHash(db DatabaseWriter, hash common.Hash, number uint64, appid ...string)
WriteCanonicalHash stores the hash assigned to a canonical block number.
func WriteChainConfig ¶
func WriteChainConfig(db DatabaseWriter, hash common.Hash, cfg map[string]*params.ChainConfig, appid ...string)
WriteChainConfig writes the chain config settings to the database.
func WriteChainConfig(db DatabaseWriter, hash common.Hash, cfg *params.ChainConfig, appid ...string) { if cfg == nil { return } data, err := json.Marshal(cfg) if err != nil { log.Crit("Failed to JSON encode chain config", "err", err) } var key = append(configPrefix, hash[:]...) if len(appid) == 1 && appid[0] != "" { key = append([]byte(appid[0]), key...) } log.Info("---写链config数据", "appid", appid[0]) if err := db.Put(key, data); err != nil { log.Crit("Failed to store chain config", "err", err) } }
func WriteDatabaseVersion ¶
func WriteDatabaseVersion(db DatabaseWriter, version int)
WriteDatabaseVersion stores the version number of the database
func WriteFastTrieProgress ¶
func WriteFastTrieProgress(db DatabaseWriter, count uint64, appid ...string)
WriteFastTrieProgress stores the fast sync trie process counter to support retrieving it across restarts.
func WriteHeadBlockHash ¶
func WriteHeadBlockHash(db DatabaseWriter, hash common.Hash, appid ...string)
WriteHeadBlockHash stores the head block's hash.
func WriteHeadFastBlockHash ¶
func WriteHeadFastBlockHash(db DatabaseWriter, hash common.Hash, appid ...string)
WriteHeadFastBlockHash stores the hash of the current fast-sync head block.
func WriteHeadHeaderHash ¶
func WriteHeadHeaderHash(db DatabaseWriter, hash common.Hash, appid ...string)
WriteHeadHeaderHash stores the hash of the current canonical head header.
func WriteHeader ¶
func WriteHeader(db DatabaseWriter, header *types.Header, appid ...string)
WriteHeader stores a block header into the database and also stores the hash- to-number mapping.
func WritePreimages ¶
func WritePreimages(db DatabaseWriter, number uint64, preimages map[common.Hash][]byte, appid ...string)
WritePreimages writes the provided set of preimages to the database. `number` is the current block number, and is used for debug messages only.
func WriteReceipts ¶
func WriteReceipts(db DatabaseWriter, hash common.Hash, number uint64, receipts types.Receipts, appid ...string)
WriteReceipts stores all the transaction receipts belonging to a block.
func WriteTxLookupEntries ¶
func WriteTxLookupEntries(db DatabaseWriter, block *types.Block, appid ...string)
WriteTxLookupEntries stores a positional metadata for every transaction from a block, enabling hash based transaction and receipt lookups.
Types ¶
type DatabaseDeleter ¶
DatabaseDeleter wraps the Delete method of a backing data store.
type DatabaseReader ¶
DatabaseReader wraps the Has and Get method of a backing data store.
type DatabaseWriter ¶
DatabaseWriter wraps the Put method of a backing data store.