github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/protocol/state/store.go (about) 1 package state 2 3 import ( 4 "github.com/bytom/bytom/database/storage" 5 "github.com/bytom/bytom/protocol/bc" 6 "github.com/bytom/bytom/protocol/bc/types" 7 ) 8 9 // Store provides storage interface for blockchain data 10 type Store interface { 11 BlockExist(*bc.Hash) bool 12 13 GetBlock(*bc.Hash) (*types.Block, error) 14 GetBlockHeader(*bc.Hash) (*types.BlockHeader, error) 15 GetStoreStatus() *BlockStoreState 16 GetTransactionsUtxo(*UtxoViewpoint, []*bc.Tx) error 17 GetUtxo(*bc.Hash) (*storage.UtxoEntry, error) 18 GetMainChainHash(uint64) (*bc.Hash, error) 19 GetContract(hash [32]byte) ([]byte, error) 20 21 GetCheckpoint(*bc.Hash) (*Checkpoint, error) 22 CheckpointsFromNode(height uint64, hash *bc.Hash) ([]*Checkpoint, error) 23 GetCheckpointsByHeight(uint64) ([]*Checkpoint, error) 24 SaveCheckpoints([]*Checkpoint) error 25 26 SaveBlock(*types.Block) error 27 SaveBlockHeader(*types.BlockHeader) error 28 SaveChainStatus(*types.BlockHeader, []*types.BlockHeader, *UtxoViewpoint, *ContractViewpoint, uint64, *bc.Hash) error 29 } 30 31 // BlockStoreState represents the core's db status 32 type BlockStoreState struct { 33 Height uint64 34 Hash *bc.Hash 35 FinalizedHeight uint64 36 FinalizedHash *bc.Hash 37 }