rawdb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2019 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Modified from go-ethereum under GNU Lesser General Public License

Modified from go-ethereum under GNU Lesser General Public License

Index

Constants

View Source
const (
	ChainTypeRoot  = ChainType(0)
	ChainTypeMinor = ChainType(1)
)
View Source
const DBLOG = "db-operation"

Variables

View Source
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)

DeleteBlock removes block data associated with a hash.

func DeleteBlockContentLookupEntry

func DeleteBlockContentLookupEntry(db DatabaseDeleter, hash common.Hash)

DeleteBlockContentLookupEntry removes all transaction data associated with a hash.

func DeleteCanonicalHash

func DeleteCanonicalHash(db DatabaseDeleter, chainType ChainType, number uint64)

DeleteCanonicalHash removes the number to hash canonical mapping.

func DeleteLatestMinorBlockHeaders

func DeleteLatestMinorBlockHeaders(db DatabaseDeleter, hash common.Hash)

func DeleteMinorBlock

func DeleteMinorBlock(db DatabaseDeleter, hash common.Hash)

DeleteBlock removes all block data associated with a hash.

func DeleteMinorBlockHeader

func DeleteMinorBlockHeader(db DatabaseDeleter, hash common.Hash)

DeleteMinorBlockHeader removes all block header data associated with a hash.

func DeleteRbCommittingHash

func DeleteRbCommittingHash(db DatabaseDeleter)

func DeleteReceipts

func DeleteReceipts(db DatabaseDeleter, hash common.Hash)

DeleteReceipts removes all receipt data associated with a block hash.

func DeleteRootBlock

func DeleteRootBlock(db DatabaseDeleter, hash common.Hash)

DeleteRootBlock removes all block data associated with a hash.

func DeleteRootBlockHeader

func DeleteRootBlockHeader(db DatabaseDeleter, hash common.Hash)

DeleteRootBlockHeader removes all block header data associated with a hash.

func DeleteTd

func DeleteTd(db DatabaseDeleter, hash common.Hash)

DeleteTd removes all block total difficulty data associated with a hash.

func DeleteValidateMinorBlockHash

func DeleteValidateMinorBlockHash(db DatabaseDeleter, hash common.Hash)

DeleteMinorBlockHeader removes all block header data associated with a hash.

func FindCommonMinorAncestor

func FindCommonMinorAncestor(db DatabaseReader, a, b *types.MinorBlockHeader) *types.MinorBlockHeader

FindCommonMinorAncestor returns the last common ancestor of two block headers

func FindCommonRootAncestor

func FindCommonRootAncestor(db DatabaseReader, a, b *types.RootBlockHeader) *types.RootBlockHeader

FindCommonRootAncestor returns the last common ancestor of two block headers

func GetMinorBlockCnt

func GetMinorBlockCnt(db DatabaseReader, fullShardID uint32, height uint32) []byte

func HasBlock

func HasBlock(db DatabaseReader, hash common.Hash) bool

HasBlock verifies the existence of a block body corresponding to the hash.

func HasHeader

func HasHeader(db DatabaseReader, hash common.Hash) bool

HasHeader verifies the existence of a block header corresponding to the hash.

func HasReceipts

func HasReceipts(db DatabaseReader, hash common.Hash) bool

HasReceipts verifies the existence of all the transaction receipts belonging to a block.

func ReadBlockContentLookupEntry

func ReadBlockContentLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint32)

ReadBlockContentLookupEntry retrieves the positional metadata associated with a transaction hash to allow retrieving the transaction or receipt by hash.

func ReadBloomBits

func ReadBloomBits(db DatabaseReader, bit uint, section uint64, head common.Hash) ([]byte, error)

ReadBloomBits retrieves the compressed bloom bit vector belonging to the given section and bit index from the.

func ReadCanonicalHash

func ReadCanonicalHash(db DatabaseReader, chainType ChainType, number uint64) common.Hash

ReadCanonicalHash retrieves the hash assigned to a canonical block number.

func ReadChainConfig

func ReadChainConfig(db DatabaseReader, hash common.Hash) *config.QuarkChainConfig

ReadChainConfig retrieves the consensus settings based on the given genesis hash.

func ReadDatabaseVersion

func ReadDatabaseVersion(db DatabaseReader) uint32

ReadDatabaseVersion retrieves the version number of the database.

func ReadFastTrieProgress

func ReadFastTrieProgress(db DatabaseReader) uint64

ReadFastTrieProgress retrieves the number of tries nodes fast synced to allow reporting correct numbers across restarts.

func ReadGenesis

func ReadGenesis(db DatabaseReader, hash common.Hash) *types.MinorBlock

func ReadHeadBlockHash

func ReadHeadBlockHash(db DatabaseReader) common.Hash

ReadHeadBlockHash retrieves the hash of the current canonical head block.

func ReadHeadFastBlockHash

func ReadHeadFastBlockHash(db DatabaseReader) common.Hash

ReadHeadFastBlockHash retrieves the hash of the current fast-sync head block.

func ReadHeadHeaderHash

func ReadHeadHeaderHash(db DatabaseReader) common.Hash

ReadHeadHeaderHash retrieves the hash of the current canonical head header.

func ReadHeaderNumber

func ReadHeaderNumber(db DatabaseReader, hash common.Hash) *uint64

ReadHeaderNumber returns the header number assigned to a hash.

func ReadLastConfirmedMinorBlockHeaderAtRootBlock

func ReadLastConfirmedMinorBlockHeaderAtRootBlock(db DatabaseReader, rHash common.Hash) common.Hash

func ReadLatestMinorBlockHeaders

func ReadLatestMinorBlockHeaders(db DatabaseReader, hash common.Hash) []*types.MinorBlockHeader

func ReadMinorBlock

func ReadMinorBlock(db DatabaseReader, hash common.Hash) *types.MinorBlock

ReadMinorBlock retrieves the block body corresponding to the hash.

func ReadMinorBlockHeader

func ReadMinorBlockHeader(db DatabaseReader, hash common.Hash) *types.MinorBlockHeader

ReadMinorBlockHeader retrieves the block header corresponding to the hash.

func ReadMinorHeaderFromRootBlock

func ReadMinorHeaderFromRootBlock(db DatabaseReader, hash common.Hash) (*types.MinorBlockHeader, common.Hash, uint32)

ReadMinorHeader retrieves a specific MinorHeader from the database, along with its added positional metadata.

func ReadPreimage

func ReadPreimage(db DatabaseReader, hash common.Hash) []byte

ReadPreimage retrieves a single preimage of the provided hash.

func ReadRbCommittingHash

func ReadRbCommittingHash(db DatabaseReader) common.Hash

func ReadReceipt

func ReadReceipt(db DatabaseReader, hash common.Hash) (*types.Receipt, common.Hash, uint32)

ReadReceipt retrieves a specific transaction receipt from the database, along with its added positional metadata.

func ReadReceipts

func ReadReceipts(db DatabaseReader, hash common.Hash) types.Receipts

ReadReceipts retrieves all the transaction receipts belonging to a block.

func ReadRootBlock

func ReadRootBlock(db DatabaseReader, hash common.Hash) *types.RootBlock

ReadRootBlock retrieves the block rootBlockBody corresponding to the hash.

func ReadRootBlockHeader

func ReadRootBlockHeader(db DatabaseReader, hash common.Hash) *types.RootBlockHeader

ReadRootBlockHeader retrieves the block header corresponding to the hash.

func ReadTd

func ReadTd(db DatabaseReader, hash common.Hash) *big.Int

ReadTd retrieves a block's total difficulty corresponding to the hash.

func ReadTotalTx

func ReadTotalTx(db DatabaseReader, hash common.Hash) *uint32

func ReadTransaction

func ReadTransaction(db DatabaseReader, hash common.Hash) (*types.Transaction, common.Hash, uint32)

ReadTransaction retrieves a specific transaction from the database, along with its added positional metadata.

func ReadValidateMinorBlockHash

func ReadValidateMinorBlockHash(db DatabaseReader, hash common.Hash) bool

ReadMinorBlockHeader retrieves the block header corresponding to the hash.

func WriteBlockContentLookupEntries

func WriteBlockContentLookupEntries(db DatabaseWriter, block types.IBlock)

WriteBlockContentLookupEntries stores a positional metadata for every transaction from a block, enabling hash based transaction and receipt lookups.

func WriteBloomBits

func WriteBloomBits(db DatabaseWriter, bit uint, section uint64, head common.Hash, bits []byte)

WriteBloomBits stores the compressed bloom bits vector belonging to the given section and bit index.

func WriteCanonicalHash

func WriteCanonicalHash(db DatabaseWriter, chainType ChainType, hash common.Hash, number uint64)

WriteCanonicalHash stores the hash assigned to a canonical block number.

func WriteChainConfig

func WriteChainConfig(db DatabaseWriter, hash common.Hash, cfg *config.QuarkChainConfig)

WriteChainConfig writes the chain config settings to the database.

func WriteConfirmedCrossShardTxList

func WriteConfirmedCrossShardTxList(db DatabaseWriter, hash common.Hash, list types.CrossShardTransactionDepositList)

func WriteCrossShardTxList

func WriteCrossShardTxList(db DatabaseWriter, hash common.Hash, list types.CrossShardTransactionDepositList)

func WriteDatabaseVersion

func WriteDatabaseVersion(db DatabaseWriter, version uint32)

WriteDatabaseVersion stores the version number of the database

func WriteFastTrieProgress

func WriteFastTrieProgress(db DatabaseWriter, count uint64)

WriteFastTrieProgress stores the fast sync trie process counter to support retrieving it across restarts.

func WriteGenesisBlock

func WriteGenesisBlock(db DatabaseWriter, rHash common.Hash, block *types.MinorBlock)

func WriteHeadBlockHash

func WriteHeadBlockHash(db DatabaseWriter, hash common.Hash)

WriteHeadBlockHash stores the head block's hash.

func WriteHeadFastBlockHash

func WriteHeadFastBlockHash(db DatabaseWriter, hash common.Hash)

WriteHeadFastBlockHash stores the hash of the current fast-sync head block.

func WriteHeadHeaderHash

func WriteHeadHeaderHash(db DatabaseWriter, hash common.Hash)

WriteHeadHeaderHash stores the hash of the current canonical head header.

func WriteLastConfirmedMinorBlockHeaderAtRootBlock

func WriteLastConfirmedMinorBlockHeaderAtRootBlock(db DatabaseWriter, rHash common.Hash, mHash common.Hash)

func WriteLatestMinorBlockHeaders

func WriteLatestMinorBlockHeaders(db DatabaseWriter, hash common.Hash, headers []*types.MinorBlockHeader)

func WriteMinorBlock

func WriteMinorBlock(db DatabaseWriter, block *types.MinorBlock)

WriteMinorBlock storea a block body into the database.

func WriteMinorBlockCnt

func WriteMinorBlockCnt(db DatabaseWriter, fullShardID uint32, height uint32, data []byte)

func WriteMinorBlockHeader

func WriteMinorBlockHeader(db DatabaseWriter, header *types.MinorBlockHeader)

func WritePreimages

func WritePreimages(db DatabaseWriter, preimages map[common.Hash][]byte)

WritePreimages writes the provided set of preimages to the database.

func WriteReceipts

func WriteReceipts(db DatabaseWriter, hash common.Hash, receipts types.Receipts)

WriteReceipts stores all the transaction receipts belonging to a block.

func WriteRootBlock

func WriteRootBlock(db DatabaseWriter, block *types.RootBlock)

WriteRootBlock storea a block rootBlockBody into the database.

func WriteRootBlockCommittingHash

func WriteRootBlockCommittingHash(db DatabaseWriter, hash common.Hash)

func WriteRootBlockHeader

func WriteRootBlockHeader(db DatabaseWriter, header *types.RootBlockHeader)

WriteRootBlockHeader stores a block header into the database and also stores the hash- to-number mapping.

func WriteTd

func WriteTd(db DatabaseWriter, hash common.Hash, td *big.Int)

WriteTd stores the total difficulty of a block into the database.

func WriteTotalTx

func WriteTotalTx(db DatabaseWriter, hash common.Hash, txCount uint32)

func WriteValidateMinorBlockHash

func WriteValidateMinorBlockHash(db DatabaseWriter, hash common.Hash)

Types

type ChainType

type ChainType byte

type DatabaseDeleter

type DatabaseDeleter interface {
	Delete(key []byte) error
}

DatabaseDeleter wraps the Delete method of a backing data store.

type DatabaseReader

type DatabaseReader interface {
	Has(key []byte) (bool, error)
	Get(key []byte) ([]byte, error)
}

DatabaseReader wraps the Has and Get method of a backing data store.

type DatabaseWriter

type DatabaseWriter interface {
	Put(key []byte, value []byte) error
}

DatabaseWriter wraps the Put method of a backing data store.

type LookupEntry

type LookupEntry struct {
	BlockHash common.Hash
	Index     uint32
}

LookupEntry is a positional metadata to help looking up the data content of a transaction or receipt given only its hash.

Jump to

Keyboard shortcuts

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