X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=protocol%2Fstore.go;h=f93b1ba7704cab83d349eeb0d57ecd5816929691;hp=ba0e1389a4b830fb3e3233c59c10972391c07759;hb=refs%2Fheads%2Ffix_log;hpb=08281341c2cb02ba11d4218576256688854790fc diff --git a/protocol/store.go b/protocol/store.go index ba0e1389..f93b1ba7 100644 --- a/protocol/store.go +++ b/protocol/store.go @@ -1,32 +1,41 @@ package protocol import ( + "errors" + "github.com/vapor/database/storage" "github.com/vapor/protocol/bc" "github.com/vapor/protocol/bc/types" "github.com/vapor/protocol/state" ) +var ( + ErrNotFoundConsensusResult = errors.New("can't find the vote result by given sequence") +) + // Store provides storage interface for blockchain data type Store interface { BlockExist(*bc.Hash) bool GetBlock(*bc.Hash) (*types.Block, error) + GetBlockHeader(*bc.Hash) (*types.BlockHeader, error) GetStoreStatus() *BlockStoreState GetTransactionStatus(*bc.Hash) (*bc.TransactionStatus, error) GetTransactionsUtxo(*state.UtxoViewpoint, []*bc.Tx) error GetUtxo(*bc.Hash) (*storage.UtxoEntry, error) + GetConsensusResult(uint64) (*state.ConsensusResult, error) + GetMainChainHash(uint64) (*bc.Hash, error) + GetBlockHashesByHeight(uint64) ([]*bc.Hash, error) - LoadBlockIndex(uint64) (*state.BlockIndex, error) SaveBlock(*types.Block, *bc.TransactionStatus) error - SaveChainStatus(*state.BlockNode, *state.UtxoViewpoint) error - - IsWithdrawSpent(hash *bc.Hash) bool - SetWithdrawSpent(hash *bc.Hash) + SaveBlockHeader(*types.BlockHeader) error + SaveChainStatus(*types.BlockHeader, *types.BlockHeader, []*types.BlockHeader, *state.UtxoViewpoint, []*state.ConsensusResult) error } // BlockStoreState represents the core's db status type BlockStoreState struct { - Height uint64 - Hash *bc.Hash + Height uint64 + Hash *bc.Hash + IrreversibleHeight uint64 + IrreversibleHash *bc.Hash }