Browse Source

add a fixme

TxsFront should not be a part of the Mempool interface
because it leaks implementation details. Instead, we need to come up
with general interface for querying the mempool so the MempoolReactor
can fetch and broadcast txs to peers.
pull/3524/head
Anton Kaliaev 6 years ago
parent
commit
101147994a
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 7 additions and 6 deletions
  1. +0
    -5
      mempool/clist_mempool.go
  2. +7
    -1
      mempool/mempool.go

+ 0
- 5
mempool/clist_mempool.go View File

@ -194,15 +194,10 @@ func (mem *CListMempool) Flush() {
_ = atomic.SwapInt64(&mem.txsBytes, 0)
}
// TxsFront returns the first transaction in the ordered list for peer
// goroutines to call .NextWait() on.
func (mem *CListMempool) TxsFront() *clist.CElement {
return mem.txs.Front()
}
// TxsWaitChan returns a channel to wait on transactions. It will be closed
// once the mempool is not empty (ie. the internal `mem.txs` has at least one
// element)
func (mem *CListMempool) TxsWaitChan() <-chan struct{} {
return mem.txs.WaitChan()
}


+ 7
- 1
mempool/mempool.go View File

@ -35,8 +35,14 @@ type Mempool interface {
// transactions (~ all available transactions).
ReapMaxTxs(max int) types.Txs
// UNSAFE
// TxsWaitChan returns a channel to wait on transactions. It will be closed
// once the mempool is not empty (ie. the internal `mem.txs` has at least one
// element)
TxsWaitChan() <-chan struct{}
// TxsFront returns the first transaction in the ordered list for peer
// goroutines to call .NextWait() on.
// FIXME: leaking implementation details!
TxsFront() *clist.CElement
// Lock locks the mempool. The consensus must be able to hold lock to safely update.


Loading…
Cancel
Save