@@ -2946,13 +2946,9 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2946
2946
pfrom.AddKnownTx (txid);
2947
2947
}
2948
2948
2949
- TxValidationState state;
2950
-
2951
2949
m_txrequest.ReceivedResponse (pfrom.GetId (), txid);
2952
2950
if (tx.HasWitness ()) m_txrequest.ReceivedResponse (pfrom.GetId (), wtxid);
2953
2951
2954
- std::list<CTransactionRef> lRemovedTxn;
2955
-
2956
2952
// We do the AlreadyHaveTx() check using wtxid, rather than txid - in the
2957
2953
// absence of witness malleation, this is strictly better, because the
2958
2954
// recent rejects filter may contain the wtxid but rarely contains
@@ -2965,8 +2961,25 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2965
2961
// already; and an adversary can already relay us old transactions
2966
2962
// (older than our recency filter) if trying to DoS us, without any need
2967
2963
// for witness malleation.
2968
- if (!AlreadyHaveTx (GenTxid (/* is_wtxid=*/ true , wtxid), m_mempool) &&
2969
- AcceptToMemoryPool (m_mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */ )) {
2964
+ if (AlreadyHaveTx (GenTxid (/* is_wtxid=*/ true , wtxid), m_mempool)) {
2965
+ if (pfrom.HasPermission (PF_FORCERELAY)) {
2966
+ // Always relay transactions received from peers with forcerelay
2967
+ // permission, even if they were already in the mempool, allowing
2968
+ // the node to function as a gateway for nodes hidden behind it.
2969
+ if (!m_mempool.exists (tx.GetHash ())) {
2970
+ LogPrintf (" Not relaying non-mempool transaction %s from forcerelay peer=%d\n " , tx.GetHash ().ToString (), pfrom.GetId ());
2971
+ } else {
2972
+ LogPrintf (" Force relaying tx %s from peer=%d\n " , tx.GetHash ().ToString (), pfrom.GetId ());
2973
+ RelayTransaction (tx.GetHash (), tx.GetWitnessHash (), m_connman);
2974
+ }
2975
+ }
2976
+ return ;
2977
+ }
2978
+
2979
+ TxValidationState state;
2980
+ std::list<CTransactionRef> lRemovedTxn;
2981
+
2982
+ if (AcceptToMemoryPool (m_mempool, state, ptx, &lRemovedTxn, false /* bypass_limits */ )) {
2970
2983
m_mempool.check (&::ChainstateActive ().CoinsTip ());
2971
2984
// As this version of the transaction was acceptable, we can forget about any
2972
2985
// requests for it.
@@ -3088,19 +3101,6 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
3088
3101
AddToCompactExtraTransactions (ptx);
3089
3102
}
3090
3103
}
3091
-
3092
- if (pfrom.HasPermission (PF_FORCERELAY)) {
3093
- // Always relay transactions received from peers with forcerelay permission, even
3094
- // if they were already in the mempool,
3095
- // allowing the node to function as a gateway for
3096
- // nodes hidden behind it.
3097
- if (!m_mempool.exists (tx.GetHash ())) {
3098
- LogPrintf (" Not relaying non-mempool transaction %s from forcerelay peer=%d\n " , tx.GetHash ().ToString (), pfrom.GetId ());
3099
- } else {
3100
- LogPrintf (" Force relaying tx %s from peer=%d\n " , tx.GetHash ().ToString (), pfrom.GetId ());
3101
- RelayTransaction (tx.GetHash (), tx.GetWitnessHash (), m_connman);
3102
- }
3103
- }
3104
3104
}
3105
3105
3106
3106
// If a tx has been detected by recentRejects, we will have reached
0 commit comments