OSDN Git Service

versoin1.1.9 (#594)
[bytom/vapor.git] / protocol / store.go
1 package protocol
2
3 import (
4         "errors"
5
6         "github.com/bytom/vapor/database/storage"
7         "github.com/bytom/vapor/protocol/bc"
8         "github.com/bytom/vapor/protocol/bc/types"
9         "github.com/bytom/vapor/protocol/state"
10 )
11
12 // predefine errors
13 var (
14         ErrNotFoundConsensusResult = errors.New("can't find the vote result by given sequence")
15 )
16
17 // Store provides storage interface for blockchain data
18 type Store interface {
19         BlockExist(*bc.Hash) bool
20
21         GetBlock(*bc.Hash) (*types.Block, error)
22         GetBlockHeader(*bc.Hash) (*types.BlockHeader, error)
23         GetStoreStatus() *BlockStoreState
24         GetTransactionStatus(*bc.Hash) (*bc.TransactionStatus, error)
25         GetTransactionsUtxo(*state.UtxoViewpoint, []*bc.Tx) error
26         GetUtxo(*bc.Hash) (*storage.UtxoEntry, error)
27         GetConsensusResult(uint64) (*state.ConsensusResult, error)
28         GetMainChainHash(uint64) (*bc.Hash, error)
29         GetBlockHashesByHeight(uint64) ([]*bc.Hash, error)
30
31         DeleteConsensusResult(uint64) error
32         DeleteBlock(*types.Block) error
33         SaveBlock(*types.Block, *bc.TransactionStatus) error
34         SaveBlockHeader(*types.BlockHeader) error
35         SaveChainStatus(*types.BlockHeader, *types.BlockHeader, []*types.BlockHeader, *state.UtxoViewpoint, []*state.ConsensusResult) error
36 }
37
38 // BlockStoreState represents the core's db status
39 type BlockStoreState struct {
40         Height             uint64
41         Hash               *bc.Hash
42         IrreversibleHeight uint64
43         IrreversibleHash   *bc.Hash
44 }