github.com/aakash4dev/cometbft@v0.38.2/state/services.go (about) 1 package state 2 3 import ( 4 "github.com/aakash4dev/cometbft/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 //go:generate ../scripts/mockery_generate.sh BlockStore 16 17 // BlockStore defines the interface used by the ConsensusState. 18 type BlockStore interface { 19 Base() int64 20 Height() int64 21 Size() int64 22 23 LoadBaseMeta() *types.BlockMeta 24 LoadBlockMeta(height int64) *types.BlockMeta 25 LoadBlock(height int64) *types.Block 26 27 SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit) 28 SaveBlockWithExtendedCommit(block *types.Block, blockParts *types.PartSet, seenCommit *types.ExtendedCommit) 29 30 PruneBlocks(height int64, state State) (uint64, int64, error) 31 32 LoadBlockByHash(hash []byte) *types.Block 33 LoadBlockMetaByHash(hash []byte) *types.BlockMeta 34 LoadBlockPart(height int64, index int) *types.Part 35 36 LoadBlockCommit(height int64) *types.Commit 37 LoadSeenCommit(height int64) *types.Commit 38 LoadBlockExtendedCommit(height int64) *types.ExtendedCommit 39 40 DeleteLatestBlock() error 41 42 Close() error 43 } 44 45 //----------------------------------------------------------------------------- 46 // evidence pool 47 48 //go:generate ../scripts/mockery_generate.sh EvidencePool 49 50 // EvidencePool defines the EvidencePool interface used by State. 51 type EvidencePool interface { 52 PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64) 53 AddEvidence(types.Evidence) error 54 Update(State, types.EvidenceList) 55 CheckEvidence(types.EvidenceList) error 56 } 57 58 // EmptyEvidencePool is an empty implementation of EvidencePool, useful for testing. It also complies 59 // to the consensus evidence pool interface 60 type EmptyEvidencePool struct{} 61 62 func (EmptyEvidencePool) PendingEvidence(int64) (ev []types.Evidence, size int64) { 63 return nil, 0 64 } 65 func (EmptyEvidencePool) AddEvidence(types.Evidence) error { return nil } 66 func (EmptyEvidencePool) Update(State, types.EvidenceList) {} 67 func (EmptyEvidencePool) CheckEvidence(types.EvidenceList) error { return nil } 68 func (EmptyEvidencePool) ReportConflictingVotes(*types.Vote, *types.Vote) {}