mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
Merge pull request #7106
a9f3d3d
Fix and improve relay from whitelisted peers (Pieter Wuille)
This commit is contained in:
commit
c894fbbb1d
1 changed files with 14 additions and 11 deletions
23
src/main.cpp
23
src/main.cpp
|
@ -4610,11 +4610,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
|
|
||||||
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);
|
||||||
|
@ -4694,13 +4690,20 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
|
|
||||||
if (pfrom->fWhitelisted && GetBoolArg("-whitelistalwaysrelay", DEFAULT_WHITELISTALWAYSRELAY)) {
|
if (pfrom->fWhitelisted && GetBoolArg("-whitelistalwaysrelay", DEFAULT_WHITELISTALWAYSRELAY)) {
|
||||||
// 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)\n", tx.GetHash().ToString(), pfrom->id, FormatStateMessage(state));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int nDoS = 0;
|
int nDoS = 0;
|
||||||
|
|
Loading…
Reference in a new issue