Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chain: remove redundant Add(tx) in zmq event #877

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions chain/bitcoind_zmq_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,6 @@ func (b *bitcoindZMQEvents) txEventHandler() {
continue
}

// Add the tx to mempool.
b.mempool.Add(tx)

select {
case b.txNtfns <- tx:
case <-b.quit:
Expand Down Expand Up @@ -418,7 +415,22 @@ func (b *bitcoindZMQEvents) mempoolPoller() {
}

// Update our local mempool with the new mempool.
b.mempool.UpdateMempoolTxes(txs)
newTxs := b.mempool.UpdateMempoolTxes(txs)

// Send the new txes to BitcoindClient, which is then
// handled in `ntfnHandler`. Note that `rawtx` will
// send the same tx, which is fine as the
// `BitcoindClient.filterTx` will take care of
// duplicate unconfirmed txes. We need to send it here
// to make sure the subscription of the spending of a
// given outpoint is not missed.
for _, tx := range newTxs {
select {
case b.txNtfns <- tx:
case <-b.quit:
return
}
}

log.Tracef("Reconciled mempool spends in %v",
time.Since(now))
Expand Down