Skip to content

Commit

Permalink
chore(mempool): remove not needed notifiedTxsAvailable
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Mar 13, 2024
1 parent ffbfb3e commit cfcd45c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions internal/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ type TxMempool struct {
txsBytes int64 // atomic: the total size of all transactions in the mempool, in bytes

// Synchronized fields, protected by mtx.
mtx *sync.RWMutex
notifiedTxsAvailable bool
mtx *sync.RWMutex
// txsAvailable is a waker that triggers when transactions are available in the mempool.
// Can be nil if not enabled with EnableTxsAvailable.
txsAvailable *tmsync.Waker
Expand Down Expand Up @@ -413,7 +412,6 @@ func (txmp *TxMempool) Update(
}

txmp.height = blockHeight
txmp.notifiedTxsAvailable = false

if newPreFn != nil {
txmp.preCheck = newPreFn
Expand Down Expand Up @@ -838,16 +836,13 @@ func (txmp *TxMempool) purgeExpiredTxs(blockHeight int64) {
// the mempool. It is a no-op if the mempool is empty or if a notification has
// already been sent.
//
// No locking is required to call this method.
// Caller should hold txmp.mtx read lock.
func (txmp *TxMempool) notifyTxsAvailable() {
if txmp.Size() == 0 {
return // nothing to do
}

if txmp.txsAvailable != nil && !txmp.notifiedTxsAvailable {
// channel cap is 1, so this will send once
txmp.notifiedTxsAvailable = true

if txmp.txsAvailable != nil {
txmp.txsAvailable.Wake()
}
}

0 comments on commit cfcd45c

Please sign in to comment.