OSDN Git Service

68544185439e433d9c616df3d4ed1cd55453556d
[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) bool
19
20         GetBlock(*bc.Hash) (*types.Block, error)
21         GetStoreStatus() *BlockStoreState
22         GetTransactionStatus(*bc.Hash) (*bc.TransactionStatus, error)
23         GetTransactionsUtxo(*state.UtxoViewpoint, []*bc.Tx) error
24         GetUtxo(*bc.Hash) (*storage.UtxoEntry, error)
25         GetVoteResult(uint64) (*state.VoteResult, error)
26
27         LoadBlockIndex(uint64) (*state.BlockIndex, error)
28         SaveBlock(*types.Block, *bc.TransactionStatus) error
29         SaveChainStatus(*state.BlockNode, *state.BlockNode, *state.UtxoViewpoint, map[uint64]*state.VoteResult) error
30 }
31
32 // BlockStoreState represents the core's db status
33 type BlockStoreState struct {
34         Height             uint64
35         Hash               *bc.Hash
36         IrreversibleHeight uint64
37         IrreversibleHash   *bc.Hash
38 }