MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / AdvertiseLocal

Function AdvertiseLocal

src/net.cpp:180–204  ·  view source on GitHub ↗

pushes our own address to a peer

Source from the content-addressed store, hash-verified

178
179// pushes our own address to a peer
180void AdvertiseLocal(CNode *pnode)
181{
182 if (fListen && pnode->fSuccessfullyConnected)
183 {
184 CAddress addrLocal = GetLocalAddress(&pnode->addr, pnode->GetLocalServices());
185 if (gArgs.GetBoolArg("-addrmantest", false)) {
186 // use IPv4 loopback during addrmantest
187 addrLocal = CAddress(CService(LookupNumeric("127.0.0.1", GetListenPort())), pnode->GetLocalServices());
188 }
189 // If discovery is enabled, sometimes give our peer the address it
190 // tells us that it sees us as in case it has a better idea of our
191 // address than we do.
192 if (IsPeerAddrLocalGood(pnode) && (!addrLocal.IsRoutable() ||
193 GetRand((GetnScore(addrLocal) > LOCAL_MANUAL) ? 8:2) == 0))
194 {
195 addrLocal.SetIP(pnode->GetAddrLocal());
196 }
197 if (addrLocal.IsRoutable() || gArgs.GetBoolArg("-addrmantest", false))
198 {
199 LogPrint(BCLog::NET, "AdvertiseLocal: advertising address %s\n", addrLocal.ToString());
200 FastRandomContext insecure_rand;
201 pnode->PushAddress(addrLocal, insecure_rand);
202 }
203 }
204}
205
206// learn a new local address
207bool AddLocal(const CService& addr, int nScore)

Callers 2

SendMessagesMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 15

GetLocalAddressFunction · 0.85
LookupNumericFunction · 0.85
GetListenPortFunction · 0.85
IsPeerAddrLocalGoodFunction · 0.85
GetRandFunction · 0.85
GetnScoreFunction · 0.85
GetBoolArgMethod · 0.80
IsRoutableMethod · 0.80
SetIPMethod · 0.80
GetAddrLocalMethod · 0.80
PushAddressMethod · 0.80
CAddressClass · 0.70

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68