github.com/arcology-network/consensus-engine@v1.9.0/state/services.go (about)

     1  package state
     2  
     3  import (
     4  	"github.com/arcology-network/consensus-engine/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  	LoadBaseMeta() *types.BlockMeta
    22  	LoadBlockMeta(height int64) *types.BlockMeta
    23  	LoadBlock(height int64) *types.Block
    24  
    25  	SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit)
    26  	SaveBlockAsync(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit)
    27  
    28  	PruneBlocks(height int64) (uint64, error)
    29  
    30  	LoadBlockByHash(hash []byte) *types.Block
    31  	LoadBlockPart(height int64, index int) *types.Part
    32  
    33  	LoadBlockCommit(height int64) *types.Commit
    34  	LoadSeenCommit(height int64) *types.Commit
    35  	SaveSeenCommit(height int64, seenCommit *types.Commit) error
    36  }
    37  
    38  //-----------------------------------------------------------------------------
    39  // evidence pool
    40  
    41  //go:generate mockery --case underscore --name EvidencePool
    42  
    43  // EvidencePool defines the EvidencePool interface used by State.
    44  type EvidencePool interface {
    45  	PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64)
    46  	AddEvidence(types.Evidence) error
    47  	Update(State, types.EvidenceList)
    48  	CheckEvidence(types.EvidenceList) error
    49  }
    50  
    51  // EmptyEvidencePool is an empty implementation of EvidencePool, useful for testing. It also complies
    52  // to the consensus evidence pool interface
    53  type EmptyEvidencePool struct{}
    54  
    55  func (EmptyEvidencePool) PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64) {
    56  	return nil, 0
    57  }
    58  func (EmptyEvidencePool) AddEvidence(types.Evidence) error                { return nil }
    59  func (EmptyEvidencePool) Update(State, types.EvidenceList)                {}
    60  func (EmptyEvidencePool) CheckEvidence(evList types.EvidenceList) error   { return nil }
    61  func (EmptyEvidencePool) ReportConflictingVotes(voteA, voteB *types.Vote) {}