There is no reason to relay transactions that have been, but are no longer, in the mempool at the time of the getdata request for the transaction.
Possible reasons for mempool removal, and my thinking why it is safe to not relay
Reason | Rationale | |
---|---|---|
EXPIRY |
Expired from mempool | Mempool expiry is 2 weeks, so does not interfere with relay at all. |
SIZELIMIT |
Removed in size limiting | A low fee transaction, which will be relayed by a different peer after GETDATA_TX_INTERVAL . Assuming it ever made it to another peer. |
REORG |
Removed for reorganization | Block races are rare, so reorgs should be rarer. Also the tx will be reaccepted from the disconnectpool later on and then relayed (TODO), so this should never be observable in practise. |
BLOCK |
Removed for block | The other peer will eventually receive the (filtered)block with the tx in it. |
CONFLICT |
Removed for conflict with in-block transaction | The peer won’t be able to add the tx to the mempool anyway. No need to waste bandwidth. |
REPLACED |
Removed for replacement | Same as above, send them the higher fee tx instead. |
This should also improve transaction relay privacy slightly. Previously any peer (even inbounds) could ask for transactions in mapRelay
, even if they were never announced to them via an inv
message. After my changes, the peer can only request transactions that were added to the mempool before the last inv
message was sent to that peer.