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.

71 lines
2.1 KiB

7 years ago
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: all types 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.
  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 int, txs Txs) error
  23. Flush()
  24. TxsAvailable() <-chan int
  25. EnableTxsAvailable()
  26. }
  27. // MockMempool is an empty implementation of a Mempool, useful for testing.
  28. // UNSTABLE
  29. type MockMempool struct {
  30. }
  31. func (m MockMempool) Lock() {}
  32. func (m MockMempool) Unlock() {}
  33. func (m MockMempool) Size() int { return 0 }
  34. func (m MockMempool) CheckTx(tx Tx, cb func(*abci.Response)) error { return nil }
  35. func (m MockMempool) Reap(n int) Txs { return Txs{} }
  36. func (m MockMempool) Update(height int, txs Txs) error { return nil }
  37. func (m MockMempool) Flush() {}
  38. func (m MockMempool) TxsAvailable() <-chan int { return make(chan int) }
  39. func (m MockMempool) EnableTxsAvailable() {}
  40. //------------------------------------------------------
  41. // blockstore
  42. // BlockStoreRPC is the block store interface used by the RPC.
  43. // UNSTABLE
  44. type BlockStoreRPC interface {
  45. Height() int
  46. LoadBlockMeta(height int) *BlockMeta
  47. LoadBlock(height int) *Block
  48. LoadBlockPart(height int, index int) *Part
  49. LoadBlockCommit(height int) *Commit
  50. LoadSeenCommit(height int) *Commit
  51. }
  52. // BlockStore defines the BlockStore interface.
  53. // UNSTABLE
  54. type BlockStore interface {
  55. BlockStoreRPC
  56. SaveBlock(block *Block, blockParts *PartSet, seenCommit *Commit)
  57. }