aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2015-11-28 16:09:30 -0800
committerGregory Maxwell <greg@xiph.org>2015-11-28 16:09:40 -0800
commitc894fbbb1dc0778628fa3f246b92d673b3f70cfa (patch)
tree90230fff8573f609b27f4f5ecbe1ba4178615690 /src
parent61457c29d735b77182b5fbd45e86d7e3db343857 (diff)
parenta9f3d3db5c0c8d1697998ed9b3e192ddbf9a31f4 (diff)
downloadbitcoin-c894fbbb1dc0778628fa3f246b92d673b3f70cfa.tar.xz
Merge pull request #7106
a9f3d3d Fix and improve relay from whitelisted peers (Pieter Wuille)
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1003dd8c36..94fcd6223b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4610,11 +4610,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
mapAlreadyAskedFor.erase(inv);
- // Check for recently rejected (and do other quick existence checks)
- if (AlreadyHave(inv))
- return true;
-
- if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
+ if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
{
mempool.check(pcoinsTip);
RelayTransaction(tx);
@@ -4694,13 +4690,20 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (pfrom->fWhitelisted && GetBoolArg("-whitelistalwaysrelay", DEFAULT_WHITELISTALWAYSRELAY)) {
// Always relay transactions received from whitelisted peers, even
- // if they were rejected from the mempool, allowing the node to
- // function as a gateway for nodes hidden behind it.
+ // if they were already in the mempool or rejected from it due
+ // to policy, allowing the node to function as a gateway for
+ // nodes hidden behind it.
//
- // FIXME: This includes invalid transactions, which means a
- // whitelisted peer could get us banned! We may want to change
- // that.
- RelayTransaction(tx);
+ // Never relay transactions that we would assign a non-zero DoS
+ // score for, as we expect peers to do the same with us in that
+ // case.
+ int nDoS = 0;
+ if (!state.IsInvalid(nDoS) || nDoS == 0) {
+ LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", tx.GetHash().ToString(), pfrom->id);
+ RelayTransaction(tx);
+ } else {
+ LogPrintf("Not relaying invalid transaction %s from whitelisted peer=%d (%s)\n", tx.GetHash().ToString(), pfrom->id, FormatStateMessage(state));
+ }
}
}
int nDoS = 0;