OSDN Git Service

writer close
[bytom/vapor.git] / protocol / store.go
1 package protocol
2
3 import (
4         "errors"
5
6         "github.com/vapor/database/storage"
7         "github.com/vapor/protocol/bc"
8         "github.com/vapor/protocol/bc/types"
9         "github.com/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         SaveBlock(*types.Block, *bc.TransactionStatus) error
31         SaveBlockHeader(*types.BlockHeader) error
32         SaveChainStatus(*types.BlockHeader, *types.BlockHeader, []*types.BlockHeader, *state.UtxoViewpoint, []*state.ConsensusResult) error
33 }
34
35 // BlockStoreState represents the core's db status
36 type BlockStoreState struct {
37         Height             uint64
38         Hash               *bc.Hash
39         IrreversibleHeight uint64
40         IrreversibleHash   *bc.Hash
41 }