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.

24 lines
1.2 KiB

  1. // The mempool pushes new txs onto the proxyAppConn.
  2. // It gets a stream of (req, res) tuples from the proxy.
  3. // The mempool stores good txs in a concurrent linked-list.
  4. // Multiple concurrent go-routines can traverse this linked-list
  5. // safely by calling .NextWait() on each element.
  6. // So we have several go-routines:
  7. // 1. Consensus calling Update() and Reap() synchronously
  8. // 2. Many mempool reactor's peer routines calling CheckTx()
  9. // 3. Many mempool reactor's peer routines traversing the txs linked list
  10. // 4. Another goroutine calling GarbageCollectTxs() periodically
  11. // To manage these goroutines, there are three methods of locking.
  12. // 1. Mutations to the linked-list is protected by an internal mtx (CList is goroutine-safe)
  13. // 2. Mutations to the linked-list elements are atomic
  14. // 3. CheckTx() calls can be paused upon Update() and Reap(), protected by .proxyMtx
  15. // Garbage collection of old elements from mempool.txs is handlde via
  16. // the DetachPrev() call, which makes old elements not reachable by
  17. // peer broadcastTxRoutine() automatically garbage collected.
  18. // TODO: Better handle abci client errors. (make it automatically handle connection errors)
  19. package mempool