@@ -5794,6 +5794,9 @@ bool SendMessages(CNode* pto)
5794
5794
pto->nNextInvSend = PoissonNextSend (nNow, INVENTORY_BROADCAST_INTERVAL >> !pto->fInbound );
5795
5795
}
5796
5796
5797
+ // Time to send but the peer has requested we not relay transactions.
5798
+ if (fSendTrickle && !pto->fRelayTxes ) pto->setInventoryTxToSend .clear ();
5799
+
5797
5800
// Respond to BIP35 mempool requests
5798
5801
if (fSendTrickle && pto->fSendMempool ) {
5799
5802
std::vector<uint256> vtxid;
@@ -5839,13 +5842,19 @@ bool SendMessages(CNode* pto)
5839
5842
for (std::set<uint256>::iterator it = pto->setInventoryTxToSend .begin (); it != pto->setInventoryTxToSend .end (); it++) {
5840
5843
vInvTx.push_back (it);
5841
5844
}
5845
+ CAmount filterrate = 0 ;
5846
+ {
5847
+ LOCK (pto->cs_feeFilter );
5848
+ filterrate = pto->minFeeFilter ;
5849
+ }
5842
5850
// Topologically and fee-rate sort the inventory we send for privacy and priority reasons.
5843
5851
// A heap is used so that not all items need sorting if only a few are being sent.
5844
5852
CompareInvMempoolOrder compareInvMempoolOrder (&mempool);
5845
5853
std::make_heap (vInvTx.begin (), vInvTx.end (), compareInvMempoolOrder);
5846
5854
// No reason to drain out at many times the network's capacity,
5847
5855
// especially since we have many peers and some will draw much shorter delays.
5848
5856
unsigned int nRelayedTransactions = 0 ;
5857
+ LOCK (pto->cs_filter );
5849
5858
while (!vInvTx.empty () && nRelayedTransactions < INVENTORY_BROADCAST_MAX) {
5850
5859
// Fetch the top element from the heap
5851
5860
std::pop_heap (vInvTx.begin (), vInvTx.end (), compareInvMempoolOrder);
@@ -5858,6 +5867,19 @@ bool SendMessages(CNode* pto)
5858
5867
if (pto->filterInventoryKnown .contains (hash)) {
5859
5868
continue ;
5860
5869
}
5870
+ // Not in the mempool anymore? don't bother sending it.
5871
+ CFeeRate feeRate;
5872
+ if (!mempool.lookupFeeRate (*it, feeRate)) {
5873
+ continue ;
5874
+ }
5875
+ if (filterrate && feeRate.GetFeePerK () < filterrate) {
5876
+ continue ;
5877
+ }
5878
+ if (pto->pfilter ) {
5879
+ CTransaction tx;
5880
+ if (!mempool.lookup (*it, tx)) continue ;
5881
+ if (!pto->pfilter ->IsRelevantAndUpdate (tx)) continue ;
5882
+ }
5861
5883
// Send
5862
5884
vInv.push_back (CInv (MSG_TX, hash));
5863
5885
nRelayedTransactions++;
0 commit comments