2018-06-04 13:46:34 -07:00
|
|
|
package state
|
2017-02-20 20:09:15 -05:00
|
|
|
|
|
|
|
import (
|
2018-06-04 13:46:34 -07:00
|
|
|
"github.com/tendermint/tendermint/types"
|
2017-02-20 20:09:15 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
//------------------------------------------------------
|
|
|
|
// blockchain services types
|
|
|
|
// NOTE: Interfaces used by RPC must be thread safe!
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
|
|
|
//------------------------------------------------------
|
|
|
|
// blockstore
|
|
|
|
|
2017-09-22 12:00:37 -04:00
|
|
|
// BlockStoreRPC is the block store interface used by the RPC.
|
2017-02-20 20:09:15 -05:00
|
|
|
type BlockStoreRPC interface {
|
2017-12-01 19:04:53 -06:00
|
|
|
Height() int64
|
2017-02-20 20:09:15 -05:00
|
|
|
|
2018-06-04 13:46:34 -07:00
|
|
|
LoadBlockMeta(height int64) *types.BlockMeta
|
|
|
|
LoadBlock(height int64) *types.Block
|
|
|
|
LoadBlockPart(height int64, index int) *types.Part
|
2017-02-20 20:09:15 -05:00
|
|
|
|
2018-06-04 13:46:34 -07:00
|
|
|
LoadBlockCommit(height int64) *types.Commit
|
|
|
|
LoadSeenCommit(height int64) *types.Commit
|
2017-02-20 20:09:15 -05:00
|
|
|
}
|
|
|
|
|
2017-11-19 01:34:11 +00:00
|
|
|
// BlockStore defines the BlockStore interface used by the ConsensusState.
|
2017-02-20 20:09:15 -05:00
|
|
|
type BlockStore interface {
|
|
|
|
BlockStoreRPC
|
2018-06-04 13:46:34 -07:00
|
|
|
SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit)
|
2017-02-20 20:09:15 -05:00
|
|
|
}
|
2017-11-19 01:34:11 +00:00
|
|
|
|
2018-06-04 13:46:34 -07:00
|
|
|
//-----------------------------------------------------------------------------------------------------
|
2017-11-19 01:34:11 +00:00
|
|
|
// evidence pool
|
|
|
|
|
|
|
|
// EvidencePool defines the EvidencePool interface used by the ConsensusState.
|
2019-02-08 18:25:48 -05:00
|
|
|
// Get/Set/Commit
|
2017-11-19 01:34:11 +00:00
|
|
|
type EvidencePool interface {
|
2018-09-21 13:00:36 +04:00
|
|
|
PendingEvidence(int64) []types.Evidence
|
2018-06-04 13:46:34 -07:00
|
|
|
AddEvidence(types.Evidence) error
|
|
|
|
Update(*types.Block, State)
|
2019-02-09 00:30:45 +01:00
|
|
|
// IsCommitted indicates if this evidence was already marked committed in another block.
|
|
|
|
IsCommitted(types.Evidence) bool
|
2017-11-19 01:34:11 +00:00
|
|
|
}
|
|
|
|
|
2019-06-21 17:29:29 -04:00
|
|
|
// MockEvidencePool is an empty implementation of EvidencePool, useful for testing.
|
2018-08-08 16:03:58 +04:00
|
|
|
type MockEvidencePool struct{}
|
2017-11-19 01:34:11 +00:00
|
|
|
|
2018-09-21 13:00:36 +04:00
|
|
|
func (m MockEvidencePool) PendingEvidence(int64) []types.Evidence { return nil }
|
2018-09-21 17:50:06 -07:00
|
|
|
func (m MockEvidencePool) AddEvidence(types.Evidence) error { return nil }
|
|
|
|
func (m MockEvidencePool) Update(*types.Block, State) {}
|
2019-02-09 00:30:45 +01:00
|
|
|
func (m MockEvidencePool) IsCommitted(types.Evidence) bool { return false }
|