This commit removes adding tx to mempool when received from rawtx zmq to prevent the same tx gets to be added multiple times since it will be notified multiple times. This also means we need to send the new tx in mempoolPoller to make sure the subscriber won't miss the event.
In details, when we subscribe to an input spend via NotifySpent, we do two things,
register it via channel rescanUpdate,
a quick lookup in our local mempool, if found return it
Meanwhile, filterTx has two relevant logic steps that,
when an unconfirmed tx is received multiple times, only the first one will be processed.
when processing the tx, it will notify if the tx is relevant, meaning it's registered via rescanUpdate.
In our second good case, if the tx is received via rawtx, then it will be sent to filterTx, but not registered via rescanUpdate. However, as long as the mempool poller also receives it and saves it to the local mempool, by the time we subscribe it, it will be found via step 2 in NotifySpent.
As in our bad case, when the tx is processed by filterTx, it won't be notified due to it's not registered, so not relevant. Then we subscribe, which registers it. However, by the time the mempool sees the tx and sends it to filterTx again, it will be ignored because filterTx has already seen it.
This commit removes adding tx to mempool when received from
rawtx
zmq to prevent the same tx gets to be added multiple times since it will be notified multiple times. This also means we need to send the new tx inmempoolPoller
to make sure the subscriber won't miss the event.In details, when we subscribe to an input spend via
NotifySpent
, we do two things,rescanUpdate
,Meanwhile,
filterTx
has two relevant logic steps that,rescanUpdate
.In our second good case, if the tx is received via
rawtx
, then it will be sent tofilterTx
, but not registered viarescanUpdate
. However, as long as the mempool poller also receives it and saves it to the local mempool, by the time we subscribe it, it will be found via step 2 inNotifySpent
.As in our bad case, when the tx is processed by
filterTx
, it won't be notified due to it's not registered, so not relevant. Then we subscribe, which registers it. However, by the time the mempool sees the tx and sends it tofilterTx
again, it will be ignored becausefilterTx
has already seen it.