From 96fad76bb1a2d3ebeb48c201ca83b79560e70285 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 11 Aug 2016 19:35:55 +0300 Subject: [PATCH] Revert part of b66928043e2fc86366372f915c6bb803f7764f79 and instead fix unknown inv handling in ProcessMessage --- src/main.cpp | 5 +++++ src/protocol.cpp | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 434fb17452456..a7ecf3db4fbf7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5479,6 +5479,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, { const CInv &inv = vInv[nInv]; + if(!inv.IsKnownType()) { + LogPrint("net", "got inv of unknown type %d: %s peer=%d\n", inv.type, inv.hash.ToString(), pfrom->id); + continue; + } + boost::this_thread::interruption_point(); pfrom->AddInventoryKnown(inv); diff --git a/src/protocol.cpp b/src/protocol.cpp index 9176fe8a4b53f..8a08c1ea17b71 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -238,7 +238,7 @@ CInv::CInv(const std::string& strType, const uint256& hashIn) } } if (i == ARRAYLEN(ppszTypeName)) - LogPrint("net", "CInv::CInv(string, uint256) : unknown type '%s'\n", strType); + throw std::out_of_range(strprintf("CInv::CInv(string, uint256): unknown type '%s'", strType)); hash = hashIn; } @@ -255,8 +255,7 @@ bool CInv::IsKnownType() const const char* CInv::GetCommand() const { if (!IsKnownType()) - LogPrint("net", "CInv::GetCommand() : type=%d unknown type\n", type); - + throw std::out_of_range(strprintf("CInv::GetCommand(): type=%d unknown type", type)); return ppszTypeName[type]; }