Skip to content

Commit fac12eb

Browse files
author
MarcoFalke
committed
net: Avoid redundant and confusing FAILED log
Every `return false` is preceeded by a detailed debug log message to explain that a disconnect or misbehavior happened. Logging another generic "FAILED" message seems redundant. Also, the size of the message and the message type has already been logged and is thus redundant as well. Finally, claiming that message processing FAILED seems odd, because the message was fully processed to the point where it was concluded that the peer should be either disconnected or marked as misbehaving.
1 parent 46bdd4b commit fac12eb

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/net_processing.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ bool static ProcessHeadersMessage(CNode& pfrom, CConnman* connman, ChainstateMan
17931793
for (const CBlockHeader& header : headers) {
17941794
if (!hashLastBlock.IsNull() && header.hashPrevBlock != hashLastBlock) {
17951795
Misbehaving(pfrom.GetId(), 20, "non-continuous headers sequence");
1796-
return false;
1796+
return true;
17971797
}
17981798
hashLastBlock = header.GetHash();
17991799
}
@@ -1809,7 +1809,7 @@ bool static ProcessHeadersMessage(CNode& pfrom, CConnman* connman, ChainstateMan
18091809
if (!chainman.ProcessNewBlockHeaders(headers, state, chainparams, &pindexLast)) {
18101810
if (state.IsInvalid()) {
18111811
MaybePunishNodeForBlock(pfrom.GetId(), state, via_compact_block, "invalid header received");
1812-
return false;
1812+
return true;
18131813
}
18141814
}
18151815

@@ -2221,7 +2221,7 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
22212221
{
22222222
LOCK(cs_main);
22232223
Misbehaving(pfrom.GetId(), 1);
2224-
return false;
2224+
return true;
22252225
}
22262226

22272227
int64_t nTime;
@@ -2247,14 +2247,14 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
22472247
{
22482248
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom.GetId(), nServices, GetDesirableServiceFlags(nServices));
22492249
pfrom.fDisconnect = true;
2250-
return false;
2250+
return true;
22512251
}
22522252

22532253
if (nVersion < MIN_PEER_PROTO_VERSION) {
22542254
// disconnect from peers older than this proto version
22552255
LogPrint(BCLog::NET, "peer=%d using obsolete version %i; disconnecting\n", pfrom.GetId(), nVersion);
22562256
pfrom.fDisconnect = true;
2257-
return false;
2257+
return true;
22582258
}
22592259

22602260
if (!vRecv.empty())
@@ -2381,7 +2381,7 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
23812381
// Must have a version message before anything else
23822382
LOCK(cs_main);
23832383
Misbehaving(pfrom.GetId(), 1);
2384-
return false;
2384+
return true;
23852385
}
23862386

23872387
// At this point, the outgoing message serialization version can't change.
@@ -2429,7 +2429,7 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
24292429
// Must have a verack message before anything else
24302430
LOCK(cs_main);
24312431
Misbehaving(pfrom.GetId(), 1);
2432-
return false;
2432+
return true;
24332433
}
24342434

24352435
if (msg_type == NetMsgType::ADDR) {
@@ -2446,7 +2446,7 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
24462446
{
24472447
LOCK(cs_main);
24482448
Misbehaving(pfrom.GetId(), 20, strprintf("message addr size() = %u", vAddr.size()));
2449-
return false;
2449+
return true;
24502450
}
24512451

24522452
// Store the new addresses
@@ -2522,7 +2522,7 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
25222522
{
25232523
LOCK(cs_main);
25242524
Misbehaving(pfrom.GetId(), 20, strprintf("message inv size() = %u", vInv.size()));
2525-
return false;
2525+
return true;
25262526
}
25272527

25282528
// We won't accept tx inv's if we're in blocks-only mode, or this is a
@@ -2588,7 +2588,7 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
25882588
{
25892589
LOCK(cs_main);
25902590
Misbehaving(pfrom.GetId(), 20, strprintf("message getdata size() = %u", vInv.size()));
2591-
return false;
2591+
return true;
25922592
}
25932593

25942594
LogPrint(BCLog::NET, "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom.GetId());
@@ -3246,7 +3246,7 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
32463246
if (nCount > MAX_HEADERS_RESULTS) {
32473247
LOCK(cs_main);
32483248
Misbehaving(pfrom.GetId(), 20, strprintf("headers message size = %u", nCount));
3249-
return false;
3249+
return true;
32503250
}
32513251
headers.resize(nCount);
32523252
for (unsigned int n = 0; n < nCount; n++) {

0 commit comments

Comments
 (0)