aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <[email protected]>2011-03-14 09:15:06 -0400
committerGavin Andresen <[email protected]>2011-03-14 09:15:06 -0400
commit27b7f3b43a3868cd4d4f97e03c35074c2ef12349 (patch)
treea39d6207cb612126097f98419dea51e580f5ba35
parentMerge branch 'dns-seed' of https://github.com/jgarzik/bitcoin (diff)
parentshy patch from Hal (diff)
downloaddiscoin-27b7f3b43a3868cd4d4f97e03c35074c2ef12349.tar.xz
discoin-27b7f3b43a3868cd4d4f97e03c35074c2ef12349.zip
Merge branch 'shy'
-rw-r--r--main.cpp4
-rw-r--r--net.h24
2 files changed, 20 insertions, 8 deletions
diff --git a/main.cpp b/main.cpp
index 298e76ecc..bfc45af28 100644
--- a/main.cpp
+++ b/main.cpp
@@ -2396,6 +2396,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 05ef5e064..7d4974fd0 100644
--- a/net.h
+++ b/net.h
@@ -572,14 +572,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()
@@ -736,6 +731,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)
{