| 433 | } |
| 434 | |
| 435 | void 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 |
no test coverage detected