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.

93 lines
2.9 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. package types
  2. import (
  3. abci "github.com/tendermint/abci/types"
  4. )
  5. // NOTE/XXX: all type definitions in this file are considered UNSTABLE
  6. //------------------------------------------------------
  7. // blockchain services types
  8. // NOTE: Interfaces used by RPC must be thread safe!
  9. //------------------------------------------------------
  10. //------------------------------------------------------
  11. // mempool
  12. // Mempool defines the mempool interface as used by the ConsensusState.
  13. // Updates to the mempool need to be synchronized with committing a block
  14. // so apps can reset their transient state on Commit
  15. // UNSTABLE
  16. type Mempool interface {
  17. Lock()
  18. Unlock()
  19. Size() int
  20. CheckTx(Tx, func(*abci.Response)) error
  21. Reap(int) Txs
  22. Update(height int64, txs Txs) error
  23. Flush()
  24. FlushAppConn() error
  25. TxsAvailable() <-chan int64
  26. EnableTxsAvailable()
  27. }
  28. // MockMempool is an empty implementation of a Mempool, useful for testing.
  29. // UNSTABLE
  30. type MockMempool struct {
  31. }
  32. func (m MockMempool) Lock() {}
  33. func (m MockMempool) Unlock() {}
  34. func (m MockMempool) Size() int { return 0 }
  35. func (m MockMempool) CheckTx(tx Tx, cb func(*abci.Response)) error { return nil }
  36. func (m MockMempool) Reap(n int) Txs { return Txs{} }
  37. func (m MockMempool) Update(height int64, txs Txs) error { return nil }
  38. func (m MockMempool) Flush() {}
  39. func (m MockMempool) FlushAppConn() error { return nil }
  40. func (m MockMempool) TxsAvailable() <-chan int64 { return make(chan int64) }
  41. func (m MockMempool) EnableTxsAvailable() {}
  42. //------------------------------------------------------
  43. // blockstore
  44. // BlockStoreRPC is the block store interface used by the RPC.
  45. // UNSTABLE
  46. type BlockStoreRPC interface {
  47. Height() int64
  48. LoadBlockMeta(height int64) *BlockMeta
  49. LoadBlock(height int64) *Block
  50. LoadBlockPart(height int64, index int) *Part
  51. LoadBlockCommit(height int64) *Commit
  52. LoadSeenCommit(height int64) *Commit
  53. }
  54. // BlockStore defines the BlockStore interface used by the ConsensusState.
  55. // UNSTABLE
  56. type BlockStore interface {
  57. BlockStoreRPC
  58. SaveBlock(block *Block, blockParts *PartSet, seenCommit *Commit)
  59. }
  60. //------------------------------------------------------
  61. // evidence pool
  62. // EvidencePool defines the EvidencePool interface used by the ConsensusState.
  63. // UNSTABLE
  64. type EvidencePool interface {
  65. PendingEvidence() []Evidence
  66. AddEvidence(Evidence) error
  67. Update(*Block)
  68. }
  69. // MockMempool is an empty implementation of a Mempool, useful for testing.
  70. // UNSTABLE
  71. type MockEvidencePool struct {
  72. }
  73. func (m MockEvidencePool) PendingEvidence() []Evidence { return nil }
  74. func (m MockEvidencePool) AddEvidence(Evidence) error { return nil }
  75. func (m MockEvidencePool) Update(*Block) {}