dbaccessor

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: LGPL-3.0 Imports: 9 Imported by: 10

Documentation

Index

Constants

View Source
const (
	RoundStep = 10
)

Variables

View Source
var (
	ErrDataLength = errors.New("data length error")
)

Functions

func DeleteBlock

func DeleteBlock(db DatabaseDeleter, hash common.Hash)

DeleteBlock removes all block data associated with a hash.

func DeleteBlockChilds

func DeleteBlockChilds(db DatabaseDeleter, hash common.Hash)

DeleteBlockChilds removes the height to hash mapping.

func DeleteBloomBits

func DeleteBloomBits(db DatabaseDeleter, bit uint, section uint64) error

func DeleteHashList

func DeleteHashList(db DatabaseDeleter, round uint64)

DeleteHashList delete the hash assigned to a block round.

func DeletePkgPoolHashList

func DeletePkgPoolHashList(db DatabaseDeleter)

func DeleteReceipts

func DeleteReceipts(db DatabaseDeleter, hash common.Hash)

DeleteReceipts removes all receipt data associated with a block hash.

func FindReorgChain

func FindReorgChain(db DatabaseReader, old, new *types.BlockHeader) []*types.BlockHeader

Return blocks of reorg chain, include common ancestor (the first element of the result slice is the common ancestor, and the last element of the result slice is the new header)

func HasBlock

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

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

func HasTxPkg

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

HasTxPkg verifies the existence of a txpkg corresponding to the hash.

func ReadBlockBody

func ReadBlockBody(db DatabaseReader, hash common.Hash) *types.BlockBody

ReadBlockBody retrieves the block corresponding to the hash.

func ReadBlockBodyRLP

func ReadBlockBodyRLP(db DatabaseReader, hash common.Hash) rlp.RawValue

ReadBlockBodyRLP retrieves a block body in its raw RLP database encoding.

func ReadBlockChilds

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

ReadBlockChilds returns the block childs assigned to a hash.

func ReadBlockHeader

func ReadBlockHeader(db DatabaseReader, hash common.Hash) *types.BlockHeader

ReadBlockHeader retrieves the block corresponding to the hash.

func ReadBlockHeaderRLP

func ReadBlockHeaderRLP(db DatabaseReader, hash common.Hash) rlp.RawValue

ReadBlockHeaderRLP retrieves a block header in its raw RLP database encoding.

func ReadBlockReceivePath

func ReadBlockReceivePath(db DatabaseReader, hash common.Hash) (types.BlockReceivePathEnum, error)

ReadBlockReceivePath retrieves the block corresponding to the hash.

func ReadBlockStateCheck

func ReadBlockStateCheck(db DatabaseReader, hash common.Hash) types.BlockStateCheckedEnum

func ReadBloom

func ReadBloom(db DatabaseReader, hash common.Hash) (*types.Bloom, error)

ReadBloom retrieves the transaction bloom belonging to a block.

func ReadBloomBits

func ReadBloomBits(db DatabaseReader, bit uint, section uint64) ([]byte, error)

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

func ReadBloomFastSyncReachHeight

func ReadBloomFastSyncReachHeight(db DatabaseReader) (uint64, error)

func ReadBloomRLP

func ReadBloomRLP(db DatabaseReader, hash common.Hash) rlp.RawValue

func ReadBloomSectionSavedFlag

func ReadBloomSectionSavedFlag(db DatabaseReader, section uint64) bool

func ReadChainConfig

func ReadChainConfig(db DatabaseReader) ([]byte, error)

ReadChainConfig retrieves the chain config.

func ReadDatabaseVersion

func ReadDatabaseVersion(db DatabaseReader) int

ReadDatabaseVersion retrieves the version number of the database.

func ReadGenesisBlockHash

func ReadGenesisBlockHash(db DatabaseReader) common.Hash

ReadGenesisBlockHash retrieves the hash of the genesis block.

func ReadHashListByBlockBackward

func ReadHashListByBlockBackward(db DatabaseReader, b *types.Block, num uint64) []*types.BlockRoundHash

ReadHashListByBlockBackward retrieves the hash older than the block b

func ReadHashListByBlockRange

func ReadHashListByBlockRange(db DatabaseReader, b1 *types.Block, b2 *types.Block) []*types.BlockRoundHash

ReadHashListByBlockRange retrieves the hash assigned to a block range (b1, b2]

func ReadHashListByRound

func ReadHashListByRound(db DatabaseReader, round uint64) types.BlockRoundHashes

ReadHashListByRound retrieves the hash assigned to a round step range(related to param round)

func ReadHashListByRoundRange

func ReadHashListByRoundRange(db DatabaseReader, r1 uint64, r2 uint64) []*types.BlockRoundHash

ReadHashListByRoundRange retrieves the hash assigned to a round range (r1, r2]

func ReadHeadBlockHash

func ReadHeadBlockHash(db DatabaseReader) common.Hash

ReadHeadBlockHash retrieves the hash of the current canonical head block.

func ReadHeightBlockMap

func ReadHeightBlockMap(db DatabaseReader, height uint64) (common.Hash, error)

func ReadHeightBlocks

func ReadHeightBlocks(db DatabaseReader, height uint64) ([]common.Hash, error)

func ReadMainBranchHeadHeightAndHash

func ReadMainBranchHeadHeightAndHash(db DatabaseReader) (uint64, common.Hash, error)

func ReadPackerNonce

func ReadPackerNonce(db DatabaseReader, coinbase common.Address) (uint64, error)

func ReadPkgPoolHashList

func ReadPkgPoolHashList(db DatabaseReader) ([]common.Hash, error)

func ReadReceipts

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

ReadReceipts retrieves all the transaction receipts belonging to a block.

func ReadReceiptsRLP

func ReadReceiptsRLP(db DatabaseReader, hash common.Hash) rlp.RawValue

func ReadTxLookupEntryRLP

func ReadTxLookupEntryRLP(db DatabaseReader, hash common.Hash) (rlp.RawValue, error)

func ReadTxPkg

func ReadTxPkg(db DatabaseReader, hash common.Hash) (*types.TxPackage, error)

func ReadTxPkgRLP

func ReadTxPkgRLP(db DatabaseReader, hash common.Hash) (rlp.RawValue, error)

func ReadTxSavedBlockHeightAndHash

func ReadTxSavedBlockHeightAndHash(db DatabaseReader) (uint64, common.Hash, error)

func WriteBlock

func WriteBlock(db DatabaseWriter, block *types.Block)

WriteBlock stores a block header into the database

func WriteBlockChilds

func WriteBlockChilds(db DatabaseWriter, hash common.Hash, childs []common.Hash)

WriteBlockChilds returns the block childs assigned to a hash.

func WriteBlockStateCheck

func WriteBlockStateCheck(db DatabaseWriter, hash common.Hash, value types.BlockStateCheckedEnum)

WriteBlockStateCheck writes the state check enum into db.

func WriteBloom

func WriteBloom(db DatabaseWriter, hash common.Hash, bloom *types.Bloom)

WriteReceipts stores the transaction bloom belonging to a block.

func WriteBloomBits

func WriteBloomBits(db DatabaseWriter, bit uint, section uint64, bits []byte)

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

func WriteBloomFastSyncReachHeight

func WriteBloomFastSyncReachHeight(db DatabaseWriter, height uint64)

func WriteBloomSectionSavedFlag

func WriteBloomSectionSavedFlag(db DatabaseWriter, section uint64, flag bool)

func WriteChainConfig

func WriteChainConfig(db DatabaseWriter, data []byte) error

WriteChainConfig writes the chain config.

func WriteDatabaseVersion

func WriteDatabaseVersion(db DatabaseWriter, version int)

WriteDatabaseVersion stores the version number of the database

func WriteGenesisBlockHash

func WriteGenesisBlockHash(db DatabaseWriter, hash common.Hash)

WriteGenesisBlockHash stores the genesis block's hash.

func WriteHashList

func WriteHashList(db DatabaseWriter, round uint64, hashList []*types.BlockRoundHash)

WriteHashList stores the hash assigned to a block round.

func WriteHeadBlockHash

func WriteHeadBlockHash(db DatabaseWriter, hash common.Hash)

WriteHeadBlockHash stores the head block's hash.

func WriteHeightBlockMap

func WriteHeightBlockMap(db DatabaseWriter, height uint64, blockFullHash common.Hash)

func WriteHeightBlocks

func WriteHeightBlocks(db DatabaseWriter, height uint64, hashes []common.Hash)

func WriteMainBranchHeadHeightAndHash

func WriteMainBranchHeadHeightAndHash(db DatabaseWriter, height uint64, hash common.Hash)

func WritePackerNonce

func WritePackerNonce(db DatabaseWriter, coinbase common.Address, nonce uint64)

func WritePkgPoolHashList

func WritePkgPoolHashList(db DatabaseWriter, hashList []common.Hash)

WritePkgPoolHashList stores the pending pkgs in pkgPool.

func WriteReceipts

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

WriteReceipts stores all the transaction receipts belonging to a block.

func WriteTxLookupEntries

func WriteTxLookupEntries(db dbwrapper.Database, blockHeight uint64, blockFullHash common.Hash, executedTxs []*types.TxWithIndex)

func WriteTxPkg

func WriteTxPkg(db DatabaseWriter, pkg *types.TxPackage)

func WriteTxSavedBlockHeightAndHash

func WriteTxSavedBlockHeightAndHash(db DatabaseWriter, height uint64, hash common.Hash)

Types

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 TxLookupEntry

type TxLookupEntry struct {
	BlockFullHash  common.Hash
	TxPackageIndex uint32
	TxIndex        uint32
}

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

func ReadTxLookupEntry

func ReadTxLookupEntry(db DatabaseReader, hash common.Hash) (TxLookupEntry, error)

type TxLookupList

type TxLookupList []TxLookupEntry

Jump to

Keyboard shortcuts

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