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.

56 lines
1.6 KiB

  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. }
  22. type MockMempool struct {
  23. }
  24. func (m MockMempool) Lock() {}
  25. func (m MockMempool) Unlock() {}
  26. func (m MockMempool) Size() int { return 0 }
  27. func (m MockMempool) CheckTx(tx Tx, cb func(*abci.Response)) error { return nil }
  28. func (m MockMempool) Reap(n int) Txs { return Txs{} }
  29. func (m MockMempool) Update(height int, txs Txs) {}
  30. func (m MockMempool) Flush() {}
  31. //------------------------------------------------------
  32. // blockstore
  33. type BlockStoreRPC interface {
  34. Height() int
  35. LoadBlockMeta(height int) *BlockMeta
  36. LoadBlock(height int) *Block
  37. LoadBlockPart(height int, index int) *Part
  38. LoadBlockCommit(height int) *Commit
  39. LoadSeenCommit(height int) *Commit
  40. }
  41. type BlockStore interface {
  42. BlockStoreRPC
  43. SaveBlock(block *Block, blockParts *PartSet, seenCommit *Commit)
  44. }