From 40805d09184befed1d1888efa2f6d7e15646cc3e Mon Sep 17 00:00:00 2001 From: Warren Togami Date: Fri, 25 Oct 2013 23:21:21 -1000 Subject: [PATCH] Disconnect nodes older than protocol version 70002 (Litecoin 0.8.3.7) Split MIN_PROTO_VERSION into INIT_PROTO_VERSION and MIN_PEER_PROTO_VERSION --- src/main.cpp | 5 ++--- src/net.h | 4 ++-- src/version.h | 7 +++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 218c3154f4..45f10aa374 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3229,10 +3229,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) CAddress addrFrom; uint64 nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if (pfrom->nVersion < MIN_PROTO_VERSION) + if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) { - // Since February 20, 2012, the protocol is initiated at version 209, - // and earlier versions are no longer supported + // disconnect from peers older than this proto version printf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString().c_str(), pfrom->nVersion); pfrom->fDisconnect = true; return false; diff --git a/src/net.h b/src/net.h index b553ef93d6..279055159d 100644 --- a/src/net.h +++ b/src/net.h @@ -222,11 +222,11 @@ public: CCriticalSection cs_inventory; std::multimap mapAskFor; - CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, MIN_PROTO_VERSION) + CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, INIT_PROTO_VERSION) { nServices = 0; hSocket = hSocketIn; - nRecvVersion = MIN_PROTO_VERSION; + nRecvVersion = INIT_PROTO_VERSION; nLastSend = 0; nLastRecv = 0; nSendBytes = 0; diff --git a/src/version.h b/src/version.h index 281159b978..5d4a8aa4e3 100644 --- a/src/version.h +++ b/src/version.h @@ -27,8 +27,11 @@ extern const std::string CLIENT_DATE; static const int PROTOCOL_VERSION = 70002; -// earlier versions not supported as of Feb 2012, and are disconnected -static const int MIN_PROTO_VERSION = 209; +// intial proto version, to be increased after version/verack negotiation +static const int INIT_PROTO_VERSION = 209; + +// disconnect from peers older than this proto version +static const int MIN_PEER_PROTO_VERSION = 70002; // nTime field added to CAddress, starting with this version; // if possible, avoid requesting addresses nodes older than this