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.
This commit is contained in:
Anton Kaliaev
2019-04-04 12:55:55 +02:00
parent ac3c571b87
commit 101147994a
2 changed files with 7 additions and 6 deletions

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()
}

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.