database

package
v0.0.0-...-829742f Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BlockHashesKeyPrefix key Prefix
	BlockHashesKeyPrefix = []byte{blockHashes, colon}

	UtxoKeyPrefix  = []byte{utxo, colon}
	ContractPrefix = []byte{contract, colon}
)
View Source
var (
	// BlockStoreKey block store key
	BlockStoreKey = []byte("blockStore")
)

Functions

func CalcBlockHashesKey

func CalcBlockHashesKey(height uint64) []byte

CalcBlockHashesKey make up hashes key with prefix + height

func CalcBlockHeaderKey

func CalcBlockHeaderKey(hash *bc.Hash) []byte

CalcBlockHeaderKey make up header key with prefix + hash

func CalcBlockTransactionsKey

func CalcBlockTransactionsKey(hash *bc.Hash) []byte

CalcBlockTransactionsKey make up txs key with prefix + hash

func CalcContractKey

func CalcContractKey(hash [32]byte) []byte

CalcContractKey calculate contract key

func CalcUtxoKey

func CalcUtxoKey(hash *bc.Hash) []byte

func GetBlockHashesByHeight

func GetBlockHashesByHeight(db dbm.DB, height uint64) ([]*bc.Hash, error)

GetBlockHashesByHeight return block hashes by given height

func GetBlockHeader

func GetBlockHeader(db dbm.DB, hash *bc.Hash) (*types.BlockHeader, error)

GetBlockHeader return the block header by given hash

func GetBlockTransactions

func GetBlockTransactions(db dbm.DB, hash *bc.Hash) ([]*types.Tx, error)

GetBlockTransactions return the block transactions by given hash

func GetMainChainHash

func GetMainChainHash(db dbm.DB, height uint64) (*bc.Hash, error)

GetMainChainHash return BlockHash by given height

func SaveUtxoView

func SaveUtxoView(batch dbm.Batch, view *state.UtxoViewpoint) error

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

A Store encapsulates storage for blockchain validation. It satisfies the interface protocol.Store, and provides additional methods for querying current data.

func NewStore

func NewStore(db dbm.DB) *Store

NewStore creates and returns a new Store object.

func (*Store) BlockExist

func (s *Store) BlockExist(hash *bc.Hash) bool

BlockExist check if the block is stored in disk

func (*Store) CheckpointsFromNode

func (s *Store) CheckpointsFromNode(height uint64, hash *bc.Hash) ([]*state.Checkpoint, error)

CheckpointsFromNode return all checkpoints from specified block height and hash

func (*Store) GetBlock

func (s *Store) GetBlock(hash *bc.Hash) (*types.Block, error)

GetBlock return the block by given hash

func (*Store) GetBlockHashesByHeight

func (s *Store) GetBlockHashesByHeight(height uint64) ([]*bc.Hash, error)

GetBlockHashesByHeight return the block hash by the specified height

func (*Store) GetBlockHeader

func (s *Store) GetBlockHeader(hash *bc.Hash) (*types.BlockHeader, error)

GetBlockHeader return the BlockHeader by given hash

func (*Store) GetBlockTransactions

func (s *Store) GetBlockTransactions(hash *bc.Hash) ([]*types.Tx, error)

GetBlockTransactions return the Block transactions by given hash

func (*Store) GetCheckpoint

func (s *Store) GetCheckpoint(hash *bc.Hash) (*state.Checkpoint, error)

func (*Store) GetCheckpointsByHeight

func (s *Store) GetCheckpointsByHeight(height uint64) ([]*state.Checkpoint, error)

GetCheckpointsByHeight return all checkpoints of specified block height

func (*Store) GetContract

func (s *Store) GetContract(hash [32]byte) ([]byte, error)

func (*Store) GetMainChainHash

func (s *Store) GetMainChainHash(height uint64) (*bc.Hash, error)

GetMainChainHash return the block hash by the specified height

func (*Store) GetStoreStatus

func (s *Store) GetStoreStatus() *state.BlockStoreState

GetStoreStatus return the BlockStoreStateJSON

func (*Store) GetTransactionsUtxo

func (s *Store) GetTransactionsUtxo(view *state.UtxoViewpoint, txs []*bc.Tx) error

GetTransactionsUtxo will return all the utxo that related to the input txs

func (*Store) GetUtxo

func (s *Store) GetUtxo(hash *bc.Hash) (*storage.UtxoEntry, error)

GetUtxo will search the utxo in db

func (*Store) SaveBlock

func (s *Store) SaveBlock(block *types.Block) error

SaveBlock persists a new block in the protocol.

func (*Store) SaveBlockHeader

func (s *Store) SaveBlockHeader(blockHeader *types.BlockHeader) error

SaveBlockHeader persists a new block header in the protocol.

func (*Store) SaveChainStatus

func (s *Store) SaveChainStatus(blockHeader *types.BlockHeader, mainBlockHeaders []*types.BlockHeader, view *state.UtxoViewpoint, contractView *state.ContractViewpoint, finalizedHeight uint64, finalizedHash *bc.Hash) error

SaveChainStatus save the core's newest status && delete old status

func (*Store) SaveCheckpoints

func (s *Store) SaveCheckpoints(checkpoints []*state.Checkpoint) error

SaveCheckpoints bulk save multiple checkpoint

Directories

Path Synopsis
Package storage is a generated protocol buffer package.
Package storage is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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