OSDN Git Service

c4da6e34830644bb889af66fc5f5c4c1fa82b6f5
[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 var (
13         ErrNotFoundConsensusResult = errors.New("can't find the vote result by given sequence")
14 )
15
16 // Store provides storage interface for blockchain data
17 type Store interface {
18         BlockExist(*bc.Hash) bool
19
20         GetBlock(*bc.Hash) (*types.Block, error)
21         GetBlockHeader(*bc.Hash) (*types.BlockHeader, error)
22         GetStoreStatus() *BlockStoreState
23         GetTransactionStatus(*bc.Hash) (*bc.TransactionStatus, error)
24         GetTransactionsUtxo(*state.UtxoViewpoint, []*bc.Tx) error
25         GetUtxo(*bc.Hash) (*storage.UtxoEntry, error)
26         GetConsensusResult(uint64) (*state.ConsensusResult, error)
27         GetMainChainHash(uint64) (*bc.Hash, error)
28         GetBlockHashesByHeight(uint64) ([]*bc.Hash, error)
29
30         DeleteBlock(*types.Block) error
31         SaveBlock(*types.Block, *bc.TransactionStatus) error
32         SaveBlockHeader(*types.BlockHeader) error
33         SaveChainStatus(*types.BlockHeader, *types.BlockHeader, []*types.BlockHeader, *state.UtxoViewpoint, []*state.ConsensusResult) error
34 }
35
36 // BlockStoreState represents the core's db status
37 type BlockStoreState struct {
38         Height             uint64
39         Hash               *bc.Hash
40         IrreversibleHeight uint64
41         IrreversibleHash   *bc.Hash
42 }