From cbc920d474b84e8ca339618b1419383000db531f Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 24 Jan 2011 10:42:17 -0500 Subject: [PATCH] shy patch from Hal --- main.cpp | 4 ++++ net.h | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index a47f3a97..7a718c73 100644 --- a/main.cpp +++ b/main.cpp @@ -2366,6 +2366,10 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) return true; } + // Be shy and don't send version until we hear + if (pfrom->fInbound) + pfrom->PushVersion(); + pfrom->fClient = !(pfrom->nServices & NODE_NETWORK); AddTimeData(pfrom->addr.ip, nTime); diff --git a/net.h b/net.h index f0708161..12e415b5 100644 --- a/net.h +++ b/net.h @@ -571,14 +571,9 @@ public: fGetAddr = false; vfSubscribe.assign(256, false); - // Push a version message - /// when NTP implemented, change to just nTime = GetAdjustedTime() - int64 nTime = (fInbound ? GetAdjustedTime() : GetTime()); - CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr); - CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost); - RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); - PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe, - nLocalHostNonce, string(pszSubVer), nBestHeight); + // Be shy and don't send version until we hear + if (!fInbound) + PushVersion(); } ~CNode() @@ -735,6 +730,19 @@ public: + void PushVersion() + { + /// when NTP implemented, change to just nTime = GetAdjustedTime() + int64 nTime = (fInbound ? GetAdjustedTime() : GetTime()); + CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr); + CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost); + RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); + PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe, + nLocalHostNonce, string(pszSubVer), nBestHeight); + } + + + void PushMessage(const char* pszCommand) {