OSDN Git Service

b3909ff8a15c45de48aa01deaf4dd33138e2229f
[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         ErrNotFoundVoteResult = 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, uint64) bool
19
20         GetBlock(*bc.Hash, uint64) (*types.Block, error)
21         GetBlockHeader(*bc.Hash, uint64) (*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         GetVoteResult(uint64) (*state.VoteResult, error)
27
28         LoadBlockIndex(uint64) (*state.BlockIndex, error)
29         SaveBlock(*types.Block, *bc.TransactionStatus) error
30         SaveBlockHeader(*types.BlockHeader) error
31         SaveChainStatus(*state.BlockNode, *state.BlockNode, *state.UtxoViewpoint, []*state.VoteResult) error
32 }
33
34 // BlockStoreState represents the core's db status
35 type BlockStoreState struct {
36         Height             uint64
37         Hash               *bc.Hash
38         IrreversibleHeight uint64
39         IrreversibleHash   *bc.Hash
40 }