@@ -4557,12 +4557,16 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
4557
4557
vRecv >> LIMITED_STRING (pfrom->strSubVer , MAX_SUBVERSION_LENGTH);
4558
4558
pfrom->cleanSubVer = SanitizeString (pfrom->strSubVer );
4559
4559
}
4560
- if (!vRecv.empty ())
4560
+ if (!vRecv.empty ()) {
4561
4561
vRecv >> pfrom->nStartingHeight ;
4562
- if (!vRecv.empty ())
4563
- vRecv >> pfrom->fRelayTxes ; // set to true after we get the first filter* message
4564
- else
4565
- pfrom->fRelayTxes = true ;
4562
+ }
4563
+ {
4564
+ LOCK (pfrom->cs_filter );
4565
+ if (!vRecv.empty ())
4566
+ vRecv >> pfrom->fRelayTxes ; // set to true after we get the first filter* message
4567
+ else
4568
+ pfrom->fRelayTxes = true ;
4569
+ }
4566
4570
4567
4571
// Disconnect if we connected to ourself
4568
4572
if (nNonce == nLocalHostNonce && nNonce > 1 )
@@ -5325,12 +5329,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
5325
5329
CBloomFilter filter;
5326
5330
vRecv >> filter;
5327
5331
5332
+ LOCK (pfrom->cs_filter );
5333
+
5328
5334
if (!filter.IsWithinSizeConstraints ())
5329
5335
// There is no excuse for sending a too-large filter
5330
5336
Misbehaving (pfrom->GetId (), 100 );
5331
5337
else
5332
5338
{
5333
- LOCK (pfrom->cs_filter );
5334
5339
delete pfrom->pfilter ;
5335
5340
pfrom->pfilter = new CBloomFilter (filter);
5336
5341
pfrom->pfilter ->UpdateEmptyFull ();
@@ -5798,6 +5803,12 @@ bool SendMessages(CNode* pto)
5798
5803
pto->nNextInvSend = PoissonNextSend (nNow, INVENTORY_BROADCAST_INTERVAL >> !pto->fInbound );
5799
5804
}
5800
5805
5806
+ // Time to send but the peer has requested we not relay transactions.
5807
+ if (fSendTrickle ) {
5808
+ LOCK (pto->cs_filter );
5809
+ if (!pto->fRelayTxes ) pto->setInventoryTxToSend .clear ();
5810
+ }
5811
+
5801
5812
// Respond to BIP35 mempool requests
5802
5813
if (fSendTrickle && pto->fSendMempool ) {
5803
5814
std::vector<uint256> vtxid;
@@ -5843,13 +5854,19 @@ bool SendMessages(CNode* pto)
5843
5854
for (std::set<uint256>::iterator it = pto->setInventoryTxToSend .begin (); it != pto->setInventoryTxToSend .end (); it++) {
5844
5855
vInvTx.push_back (it);
5845
5856
}
5857
+ CAmount filterrate = 0 ;
5858
+ {
5859
+ LOCK (pto->cs_feeFilter );
5860
+ filterrate = pto->minFeeFilter ;
5861
+ }
5846
5862
// Topologically and fee-rate sort the inventory we send for privacy and priority reasons.
5847
5863
// A heap is used so that not all items need sorting if only a few are being sent.
5848
5864
CompareInvMempoolOrder compareInvMempoolOrder (&mempool);
5849
5865
std::make_heap (vInvTx.begin (), vInvTx.end (), compareInvMempoolOrder);
5850
5866
// No reason to drain out at many times the network's capacity,
5851
5867
// especially since we have many peers and some will draw much shorter delays.
5852
5868
unsigned int nRelayedTransactions = 0 ;
5869
+ LOCK (pto->cs_filter );
5853
5870
while (!vInvTx.empty () && nRelayedTransactions < INVENTORY_BROADCAST_MAX) {
5854
5871
// Fetch the top element from the heap
5855
5872
std::pop_heap (vInvTx.begin (), vInvTx.end (), compareInvMempoolOrder);
@@ -5862,6 +5879,19 @@ bool SendMessages(CNode* pto)
5862
5879
if (pto->filterInventoryKnown .contains (hash)) {
5863
5880
continue ;
5864
5881
}
5882
+ // Not in the mempool anymore? don't bother sending it.
5883
+ CFeeRate feeRate;
5884
+ if (!mempool.lookupFeeRate (hash, feeRate)) {
5885
+ continue ;
5886
+ }
5887
+ if (filterrate && feeRate.GetFeePerK () < filterrate) {
5888
+ continue ;
5889
+ }
5890
+ if (pto->pfilter ) {
5891
+ CTransaction tx;
5892
+ if (!mempool.lookup (hash, tx)) continue ;
5893
+ if (!pto->pfilter ->IsRelevantAndUpdate (tx)) continue ;
5894
+ }
5865
5895
// Send
5866
5896
vInv.push_back (CInv (MSG_TX, hash));
5867
5897
nRelayedTransactions++;
0 commit comments