shy patch from Hal

This commit is contained in:
Gavin Andresen 2011-01-24 10:42:17 -05:00
parent f36b494aeb
commit cbc920d474
2 changed files with 20 additions and 8 deletions

View file

@ -2366,6 +2366,10 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return true; return true;
} }
// Be shy and don't send version until we hear
if (pfrom->fInbound)
pfrom->PushVersion();
pfrom->fClient = !(pfrom->nServices & NODE_NETWORK); pfrom->fClient = !(pfrom->nServices & NODE_NETWORK);
AddTimeData(pfrom->addr.ip, nTime); AddTimeData(pfrom->addr.ip, nTime);

24
net.h
View file

@ -571,14 +571,9 @@ public:
fGetAddr = false; fGetAddr = false;
vfSubscribe.assign(256, false); vfSubscribe.assign(256, false);
// Push a version message // Be shy and don't send version until we hear
/// when NTP implemented, change to just nTime = GetAdjustedTime() if (!fInbound)
int64 nTime = (fInbound ? GetAdjustedTime() : GetTime()); PushVersion();
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);
} }
~CNode() ~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) void PushMessage(const char* pszCommand)
{ {