github.com/evdatsion/aphelion-dpos-bft@v0.32.1/state/services.go (about) 1 package state 2 3 import ( 4 "github.com/evdatsion/aphelion-dpos-bft/types" 5 ) 6 7 //------------------------------------------------------ 8 // blockchain services types 9 // NOTE: Interfaces used by RPC must be thread safe! 10 //------------------------------------------------------ 11 12 //------------------------------------------------------ 13 // blockstore 14 15 // BlockStoreRPC is the block store interface used by the RPC. 16 type BlockStoreRPC interface { 17 Height() int64 18 19 LoadBlockMeta(height int64) *types.BlockMeta 20 LoadBlock(height int64) *types.Block 21 LoadBlockPart(height int64, index int) *types.Part 22 23 LoadBlockCommit(height int64) *types.Commit 24 LoadSeenCommit(height int64) *types.Commit 25 } 26 27 // BlockStore defines the BlockStore interface used by the ConsensusState. 28 type BlockStore interface { 29 BlockStoreRPC 30 SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit) 31 } 32 33 //----------------------------------------------------------------------------------------------------- 34 // evidence pool 35 36 // EvidencePool defines the EvidencePool interface used by the ConsensusState. 37 // Get/Set/Commit 38 type EvidencePool interface { 39 PendingEvidence(int64) []types.Evidence 40 AddEvidence(types.Evidence) error 41 Update(*types.Block, State) 42 // IsCommitted indicates if this evidence was already marked committed in another block. 43 IsCommitted(types.Evidence) bool 44 } 45 46 // MockEvidencePool is an empty implementation of EvidencePool, useful for testing. 47 type MockEvidencePool struct{} 48 49 func (m MockEvidencePool) PendingEvidence(int64) []types.Evidence { return nil } 50 func (m MockEvidencePool) AddEvidence(types.Evidence) error { return nil } 51 func (m MockEvidencePool) Update(*types.Block, State) {} 52 func (m MockEvidencePool) IsCommitted(types.Evidence) bool { return false }