MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / PushVersion

Method PushVersion

src/net.cpp:435–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433}
434
435void CNode::PushVersion()
436{
437 int nBestHeight = g_signals.GetHeight().get_value_or(0);
438
439 int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime());
440 CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
441 CAddress addrMe = CAddress(CService(), nLocalServices);
442 GetRandBytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
443 if (fLogIPs)
444 LogPrint("net", "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), addrYou.ToString(), id);
445 else
446 LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id);
447
448 // Stealth mode: pretend to be like Bitcoin Core to hide from DoS attackers.
449 if (Opt().IsStealthMode()) {
450 uint64_t services = 0;
451 if (nLocalServices & NODE_NETWORK)
452 services = NODE_NETWORK;
453
454 PushMessage("version", 70002, services, nTime, addrYou, addrMe,
455 nLocalHostNonce, XTSubVersion(0), nBestHeight, true);
456 } else {
457 int nMaxBlockSize = g_signals.GetMaxBlockSize().get_value_or(0);
458 PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
459 nLocalHostNonce, XTSubVersion(nMaxBlockSize), nBestHeight, true);
460 }
461}
462
463
464

Callers 1

ProcessMessageFunction · 0.80

Calls 12

GetAdjustedTimeFunction · 0.85
GetTimeFunction · 0.85
IsProxyFunction · 0.85
GetRandBytesFunction · 0.85
OptClass · 0.85
XTSubVersionFunction · 0.85
GetHeightMethod · 0.80
IsRoutableMethod · 0.80
IsStealthModeMethod · 0.80
CAddressClass · 0.70
CServiceClass · 0.70
ToStringMethod · 0.45

Tested by

no test coverage detected