Auto merge of #1411 - bitcartel:master_bitcoin_7106, r=daira
Upstream patch: Fix and improve relay from whitelisted peers https://github.com/bitcoin/bitcoin/pull/7106 a9f3d3db5c0c8d1697998ed9b3e192ddbf9a31f4 An extra commit modifies the log message string, otherwise there are are a number of commits that need be to backported to add methods e.g. GetDebugMessage. These commits modify the interface in consensus/validation.h so there are conflicts to be resolved. e.g. 9003c7c a9ac95c 5f12263 fbf44e6
This commit is contained in:
commit
976479f824
24
src/main.cpp
24
src/main.cpp
|
@ -4660,11 +4660,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
pfrom->setAskFor.erase(inv.hash);
|
pfrom->setAskFor.erase(inv.hash);
|
||||||
mapAlreadyAskedFor.erase(inv);
|
mapAlreadyAskedFor.erase(inv);
|
||||||
|
|
||||||
// Check for recently rejected (and do other quick existence checks)
|
if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
|
||||||
if (AlreadyHave(inv))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
|
|
||||||
{
|
{
|
||||||
mempool.check(pcoinsTip);
|
mempool.check(pcoinsTip);
|
||||||
RelayTransaction(tx);
|
RelayTransaction(tx);
|
||||||
|
@ -4745,13 +4741,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
|
|
||||||
if (pfrom->fWhitelisted) {
|
if (pfrom->fWhitelisted) {
|
||||||
// Always relay transactions received from whitelisted peers, even
|
// Always relay transactions received from whitelisted peers, even
|
||||||
// if they were rejected from the mempool, allowing the node to
|
// if they were already in the mempool or rejected from it due
|
||||||
// function as a gateway for nodes hidden behind it.
|
// to policy, allowing the node to function as a gateway for
|
||||||
|
// nodes hidden behind it.
|
||||||
//
|
//
|
||||||
// FIXME: This includes invalid transactions, which means a
|
// Never relay transactions that we would assign a non-zero DoS
|
||||||
// whitelisted peer could get us banned! We may want to change
|
// score for, as we expect peers to do the same with us in that
|
||||||
// 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);
|
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;
|
int nDoS = 0;
|
||||||
|
|
Loading…
Reference in New Issue