database

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: AGPL-3.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const UtxoPreFix = "UT:"

Variables

View Source
var (
	BlockStoreKey     = []byte("blockStore")
	BlockPrefix       = []byte("B:")
	BlockHeaderPrefix = []byte("BH:")
	TxStatusPrefix    = []byte("BTS:")
)

Functions

func CalcBlockHeaderKey

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

func CalcBlockKey

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

func CalcTxStatusKey

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

func CalcUtxoKey

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

func GetBlock

func GetBlock(db dbm.DB, hash *bc.Hash) (*types.Block, error)

GetBlock return the block by given hash

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) GetBlock

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

GetBlock return the block by given hash

func (*Store) GetStoreStatus

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

GetStoreStatus return the BlockStoreStateJSON

func (*Store) GetTransactionStatus

func (s *Store) GetTransactionStatus(hash *bc.Hash) (*bc.TransactionStatus, error)

GetTransactionStatus will return the utxo that related to the block hash

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) LoadBlockIndex

func (s *Store) LoadBlockIndex(stateBestHeight uint64) (*state.BlockIndex, error)

func (*Store) SaveBlock

func (s *Store) SaveBlock(block *types.Block, ts *bc.TransactionStatus) error

SaveBlock persists a new block in the protocol.

func (*Store) SaveChainStatus

func (s *Store) SaveChainStatus(node *state.BlockNode, view *state.UtxoViewpoint) error

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

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