mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
[net processing] Always supply debug message to Misbehaving()
Misbehaving() could optionally take a debug string for printing to the log file. Make this mandatory and always provide the string. A couple of additional minor changes: - remove the unnecessary forward declaration of Misbehaving() - don't include the nodeid or newline in the passed debug message. Misbehaving() adds these itself.
This commit is contained in:
parent
634144a1c2
commit
d15b3afb4c
1 changed files with 9 additions and 12 deletions
|
@ -157,9 +157,6 @@ std::map<uint256, std::map<uint256, COrphanTx>::iterator> g_orphans_by_wtxid GUA
|
|||
|
||||
void EraseOrphansFor(NodeId peer);
|
||||
|
||||
/** Increase a node's misbehavior score. */
|
||||
void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="") EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
// Internal stuff
|
||||
namespace {
|
||||
/** Number of nodes with fSyncStarted. */
|
||||
|
@ -1799,7 +1796,7 @@ inline void static SendBlockTransactions(const CBlock& block, const BlockTransac
|
|||
for (size_t i = 0; i < req.indexes.size(); i++) {
|
||||
if (req.indexes[i] >= block.vtx.size()) {
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom.GetId(), 100, strprintf("Peer %d sent us a getblocktxn with out-of-bounds tx indices", pfrom.GetId()));
|
||||
Misbehaving(pfrom.GetId(), 100, "getblocktxn with out-of-bounds tx indices");
|
||||
return;
|
||||
}
|
||||
resp.txn[i] = block.vtx[req.indexes[i]];
|
||||
|
@ -1848,7 +1845,7 @@ static void ProcessHeadersMessage(CNode& pfrom, CConnman& connman, ChainstateMan
|
|||
UpdateBlockAvailability(pfrom.GetId(), headers.back().GetHash());
|
||||
|
||||
if (nodestate->nUnconnectingHeaders % MAX_UNCONNECTING_HEADERS == 0) {
|
||||
Misbehaving(pfrom.GetId(), 20);
|
||||
Misbehaving(pfrom.GetId(), 20, strprintf("%d non-connecting headers", nodestate->nUnconnectingHeaders));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2307,7 +2304,7 @@ void ProcessMessage(
|
|||
if (pfrom.nVersion != 0)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom.GetId(), 1);
|
||||
Misbehaving(pfrom.GetId(), 1, "redundant version message");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2468,7 +2465,7 @@ void ProcessMessage(
|
|||
if (pfrom.nVersion == 0) {
|
||||
// Must have a version message before anything else
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom.GetId(), 1);
|
||||
Misbehaving(pfrom.GetId(), 1, "non-version message before version handshake");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2535,7 +2532,7 @@ void ProcessMessage(
|
|||
if (!pfrom.fSuccessfullyConnected) {
|
||||
// Must have a verack message before anything else
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom.GetId(), 1);
|
||||
Misbehaving(pfrom.GetId(), 1, "non-verack message before version handshake");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3203,7 +3200,7 @@ void ProcessMessage(
|
|||
ReadStatus status = partialBlock.InitData(cmpctblock, vExtraTxnForCompact);
|
||||
if (status == READ_STATUS_INVALID) {
|
||||
MarkBlockAsReceived(pindex->GetBlockHash()); // Reset in-flight state in case Misbehaving does not result in a disconnect
|
||||
Misbehaving(pfrom.GetId(), 100, strprintf("Peer %d sent us invalid compact block\n", pfrom.GetId()));
|
||||
Misbehaving(pfrom.GetId(), 100, "invalid compact block");
|
||||
return;
|
||||
} else if (status == READ_STATUS_FAILED) {
|
||||
// Duplicate txindexes, the block is now in-flight, so just request it
|
||||
|
@ -3336,7 +3333,7 @@ void ProcessMessage(
|
|||
ReadStatus status = partialBlock.FillBlock(*pblock, resp.txn);
|
||||
if (status == READ_STATUS_INVALID) {
|
||||
MarkBlockAsReceived(resp.blockhash); // Reset in-flight state in case Misbehaving does not result in a disconnect
|
||||
Misbehaving(pfrom.GetId(), 100, strprintf("Peer %d sent us invalid compact block/non-matching block transactions\n", pfrom.GetId()));
|
||||
Misbehaving(pfrom.GetId(), 100, "invalid compact block/non-matching block transactions");
|
||||
return;
|
||||
} else if (status == READ_STATUS_FAILED) {
|
||||
// Might have collided, fall back to getdata now :(
|
||||
|
@ -3605,7 +3602,7 @@ void ProcessMessage(
|
|||
{
|
||||
// There is no excuse for sending a too-large filter
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom.GetId(), 100);
|
||||
Misbehaving(pfrom.GetId(), 100, "too-large bloom filter");
|
||||
}
|
||||
else if (pfrom.m_tx_relay != nullptr)
|
||||
{
|
||||
|
@ -3639,7 +3636,7 @@ void ProcessMessage(
|
|||
}
|
||||
if (bad) {
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom.GetId(), 100);
|
||||
Misbehaving(pfrom.GetId(), 100, "bad filteradd message");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue