Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 2,951 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::VERSION) { | ||||
// Potentially mark this peer as a preferred download peer. | // Potentially mark this peer as a preferred download peer. | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
UpdatePreferredDownload(pfrom, State(pfrom.GetId())); | UpdatePreferredDownload(pfrom, State(pfrom.GetId())); | ||||
} | } | ||||
if (!pfrom.IsInboundConn() && !pfrom.IsBlockOnlyConn()) { | if (!pfrom.IsInboundConn() && !pfrom.IsBlockOnlyConn()) { | ||||
// For outbound peers, we try to relay our address (so that other | |||||
// nodes can try to find us more quickly, as we have no guarantee | |||||
// that an outbound peer is even aware of how to reach us) and do a | |||||
// one-time address fetch (to help populate/update our addrman). If | |||||
// we're starting up for the first time, our addrman may be pretty | |||||
// empty and no one will know who we are, so these mechanisms are | |||||
// important to help us connect to the network. | |||||
// | |||||
// We also update the addrman to record connection success for | |||||
// these peers (which include OUTBOUND_FULL_RELAY and FEELER | |||||
// connections) so that addrman will have an up-to-date notion of | |||||
// which peers are online and available. | |||||
// | |||||
// We skip these operations for BLOCK_RELAY peers to avoid | |||||
// potentially leaking information about our BLOCK_RELAY | |||||
// connections via the addrman or address relay. | |||||
if (fListen && !::ChainstateActive().IsInitialBlockDownload()) { | if (fListen && !::ChainstateActive().IsInitialBlockDownload()) { | ||||
CAddress addr = | CAddress addr = | ||||
GetLocalAddress(&pfrom.addr, pfrom.GetLocalServices()); | GetLocalAddress(&pfrom.addr, pfrom.GetLocalServices()); | ||||
FastRandomContext insecure_rand; | FastRandomContext insecure_rand; | ||||
if (addr.IsRoutable()) { | if (addr.IsRoutable()) { | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
"ProcessMessages: advertising address %s\n", | "ProcessMessages: advertising address %s\n", | ||||
addr.ToString()); | addr.ToString()); | ||||
pfrom.PushAddress(addr, insecure_rand); | pfrom.PushAddress(addr, insecure_rand); | ||||
} else if (IsPeerAddrLocalGood(&pfrom)) { | } else if (IsPeerAddrLocalGood(&pfrom)) { | ||||
addr.SetIP(addrMe); | addr.SetIP(addrMe); | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
"ProcessMessages: advertising address %s\n", | "ProcessMessages: advertising address %s\n", | ||||
addr.ToString()); | addr.ToString()); | ||||
pfrom.PushAddress(addr, insecure_rand); | pfrom.PushAddress(addr, insecure_rand); | ||||
} | } | ||||
} | } | ||||
// Get recent addresses | // Get recent addresses | ||||
m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version) | m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version) | ||||
.Make(NetMsgType::GETADDR)); | .Make(NetMsgType::GETADDR)); | ||||
pfrom.fGetAddr = true; | pfrom.fGetAddr = true; | ||||
// Moves address from New to Tried table in Addrman, resolves | |||||
// tried-table collisions, etc. | |||||
m_connman.MarkAddressGood(pfrom.addr); | m_connman.MarkAddressGood(pfrom.addr); | ||||
} | } | ||||
std::string remoteAddr; | std::string remoteAddr; | ||||
if (fLogIPs) { | if (fLogIPs) { | ||||
remoteAddr = ", peeraddr=" + pfrom.addr.ToString(); | remoteAddr = ", peeraddr=" + pfrom.addr.ToString(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,888 Lines • Show Last 20 Lines |