@@ -4610,11 +4610,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
4610
4610
4611
4611
mapAlreadyAskedFor.erase (inv);
4612
4612
4613
- // Check for recently rejected (and do other quick existence checks)
4614
- if (AlreadyHave (inv))
4615
- return true ;
4616
-
4617
- if (AcceptToMemoryPool (mempool, state, tx, true , &fMissingInputs ))
4613
+ if (!AlreadyHave (inv) && AcceptToMemoryPool (mempool, state, tx, true , &fMissingInputs ))
4618
4614
{
4619
4615
mempool.check (pcoinsTip);
4620
4616
RelayTransaction (tx);
@@ -4694,13 +4690,20 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
4694
4690
4695
4691
if (pfrom->fWhitelisted && GetBoolArg (" -whitelistalwaysrelay" , DEFAULT_WHITELISTALWAYSRELAY)) {
4696
4692
// Always relay transactions received from whitelisted peers, even
4697
- // if they were rejected from the mempool, allowing the node to
4698
- // function as a gateway for nodes hidden behind it.
4693
+ // if they were already in the mempool or rejected from it due
4694
+ // to policy, allowing the node to function as a gateway for
4695
+ // nodes hidden behind it.
4699
4696
//
4700
- // FIXME: This includes invalid transactions, which means a
4701
- // whitelisted peer could get us banned! We may want to change
4702
- // that.
4703
- RelayTransaction (tx);
4697
+ // Never relay transactions that we would assign a non-zero DoS
4698
+ // score for, as we expect peers to do the same with us in that
4699
+ // case.
4700
+ int nDoS = 0 ;
4701
+ if (!state.IsInvalid (nDoS) || nDoS == 0 ) {
4702
+ LogPrintf (" Force relaying tx %s from whitelisted peer=%d\n " , tx.GetHash ().ToString (), pfrom->id );
4703
+ RelayTransaction (tx);
4704
+ } else {
4705
+ LogPrintf (" Not relaying invalid transaction %s from whitelisted peer=%d (%s)\n " , tx.GetHash ().ToString (), pfrom->id , FormatStateMessage (state));
4706
+ }
4704
4707
}
4705
4708
}
4706
4709
int nDoS = 0 ;
0 commit comments