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.

61 lines
1.8 KiB

7 years ago
  1. package types
  2. import (
  3. abci "github.com/tendermint/abci/types"
  4. )
  5. //------------------------------------------------------
  6. // blockchain services types
  7. // NOTE: Interfaces used by RPC must be thread safe!
  8. //------------------------------------------------------
  9. //------------------------------------------------------
  10. // mempool
  11. // Updates to the mempool need to be synchronized with committing a block
  12. // so apps can reset their transient state on Commit
  13. type Mempool interface {
  14. Lock()
  15. Unlock()
  16. Size() int
  17. CheckTx(Tx, func(*abci.Response)) error
  18. Reap(int) Txs
  19. Update(height int, txs Txs)
  20. Flush()
  21. TxsAvailable() chan int
  22. EnableTxsAvailable()
  23. }
  24. type MockMempool struct {
  25. }
  26. func (m MockMempool) Lock() {}
  27. func (m MockMempool) Unlock() {}
  28. func (m MockMempool) Size() int { return 0 }
  29. func (m MockMempool) CheckTx(tx Tx, cb func(*abci.Response)) error { return nil }
  30. func (m MockMempool) Reap(n int) Txs { return Txs{} }
  31. func (m MockMempool) Update(height int, txs Txs) {}
  32. func (m MockMempool) Flush() {}
  33. func (m MockMempool) TxsAvailable() chan int { return make(chan int) }
  34. func (m MockMempool) EnableTxsAvailable() {}
  35. //------------------------------------------------------
  36. // blockstore
  37. type BlockStoreRPC interface {
  38. Height() int
  39. LoadBlockMeta(height int) *BlockMeta
  40. LoadBlock(height int) *Block
  41. LoadBlockPart(height int, index int) *Part
  42. LoadBlockCommit(height int) *Commit
  43. LoadSeenCommit(height int) *Commit
  44. }
  45. type BlockStore interface {
  46. BlockStoreRPC
  47. SaveBlock(block *Block, blockParts *PartSet, seenCommit *Commit)
  48. }