Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream patch: Fix and improve relay from whitelisted peers #1411

Merged
merged 3 commits into from
Sep 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4659,11 +4659,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);
Expand Down Expand Up @@ -4744,13 +4740,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,

if (pfrom->fWhitelisted) {
// 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 (code %d))\n",
tx.GetHash().ToString(), pfrom->id, state.GetRejectReason(), state.GetRejectCode());
}
}
}
int nDoS = 0;
Expand Down