You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

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