github.com/okex/exchain@v1.8.0/libs/tendermint/state/services.go (about)

     1  package state
     2  
     3  import (
     4  	"github.com/okex/exchain/libs/tendermint/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  // BlockStore defines the interface used by the ConsensusState.
    16  type BlockStore interface {
    17  	Base() int64
    18  	Height() int64
    19  	Size() int64
    20  
    21  	LoadBlockMeta(height int64) *types.BlockMeta
    22  	LoadBlock(height int64) *types.Block
    23  
    24  	SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit)
    25  
    26  	PruneBlocks(height int64) (uint64, error)
    27  	DeleteBlocksFromTop(height int64) (uint64, error)
    28  
    29  	LoadBlockByHash(hash []byte) *types.Block
    30  	LoadBlockPart(height int64, index int) *types.Part
    31  
    32  	LoadBlockCommit(height int64) *types.Commit
    33  	LoadSeenCommit(height int64) *types.Commit
    34  }
    35  
    36  //-----------------------------------------------------------------------------
    37  // evidence pool
    38  
    39  // EvidencePool defines the EvidencePool interface used by the ConsensusState.
    40  // Get/Set/Commit
    41  type EvidencePool interface {
    42  	PendingEvidence(int64) []types.Evidence
    43  	AddEvidence(types.Evidence) error
    44  	Update(*types.Block, State)
    45  	// IsCommitted indicates if this evidence was already marked committed in another block.
    46  	IsCommitted(types.Evidence) bool
    47  }
    48  
    49  // MockEvidencePool is an empty implementation of EvidencePool, useful for testing.
    50  type MockEvidencePool struct{}
    51  
    52  func (m MockEvidencePool) PendingEvidence(int64) []types.Evidence { return nil }
    53  func (m MockEvidencePool) AddEvidence(types.Evidence) error       { return nil }
    54  func (m MockEvidencePool) Update(*types.Block, State)             {}
    55  func (m MockEvidencePool) IsCommitted(types.Evidence) bool        { return false }