OSDN Git Service

Rollback pr3 (#496)
[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         DeleteConsensusResult(uint64) error
31         DeleteBlock(*types.Block) error
32         SaveBlock(*types.Block, *bc.TransactionStatus) error
33         SaveBlockHeader(*types.BlockHeader) error
34         SaveChainStatus(*types.BlockHeader, *types.BlockHeader, []*types.BlockHeader, *state.UtxoViewpoint, []*state.ConsensusResult) error
35 }
36
37 // BlockStoreState represents the core's db status
38 type BlockStoreState struct {
39         Height             uint64
40         Hash               *bc.Hash
41         IrreversibleHeight uint64
42         IrreversibleHash   *bc.Hash
43 }