X Tutup
Skip to content

Commit c89611e

Browse files
laanwjinstagibbs
authored andcommitted
net: Log to net category for exceptions in ProcessMessages
Remove the forest of special exceptions, and simply log a short message to the NET logging category when an exception happens during packet processing. It is not good to panick end users with errors that any peer can generate (let alone writing to stderr). Github-Pull: bitcoin#17762 Rebased-From: 4d88c3d
1 parent a05d14d commit c89611e

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,35 +3090,10 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
30903090
return false;
30913091
if (!pfrom->vRecvGetData.empty())
30923092
fMoreWork = true;
3093-
}
3094-
catch (const std::ios_base::failure& e)
3095-
{
3096-
if (m_enable_bip61) {
3097-
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_MALFORMED, std::string("error parsing message")));
3098-
}
3099-
if (strstr(e.what(), "end of data")) {
3100-
// Allow exceptions from under-length message on vRecv
3101-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught, normally caused by a message being shorter than its stated length\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3102-
} else if (strstr(e.what(), "size too large")) {
3103-
// Allow exceptions from over-long size
3104-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3105-
} else if (strstr(e.what(), "non-canonical ReadCompactSize()")) {
3106-
// Allow exceptions from non-canonical encoding
3107-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3108-
} else if (strstr(e.what(), "Superfluous witness record")) {
3109-
// Allow exceptions from illegal witness encoding
3110-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3111-
} else if (strstr(e.what(), "Unknown transaction optional data")) {
3112-
// Allow exceptions from unknown witness encoding
3113-
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
3114-
} else {
3115-
PrintExceptionContinue(&e, "ProcessMessages()");
3116-
}
3117-
}
3118-
catch (const std::exception& e) {
3119-
PrintExceptionContinue(&e, "ProcessMessages()");
3093+
} catch (const std::exception& e) {
3094+
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' (%s) caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what(), typeid(e).name());
31203095
} catch (...) {
3121-
PrintExceptionContinue(nullptr, "ProcessMessages()");
3096+
LogPrint(BCLog::NET, "%s(%s, %u bytes): Unknown exception caught\n", __func__, SanitizeString(strCommand), nMessageSize);
31223097
}
31233098

31243099
if (!fRet) {

0 commit comments

Comments
 (0)
X Tutup