MCPcopy Create free account
hub / github.com/ElementsProject/elements / ConvertSeeds

Function ConvertSeeds

src/net.cpp:183–202  ·  view source on GitHub ↗

Convert the serialized seeds into usable address objects.

Source from the content-addressed store, hash-verified

181
182//! Convert the serialized seeds into usable address objects.
183static std::vector<CAddress> ConvertSeeds(const std::vector<uint8_t> &vSeedsIn)
184{
185 // It'll only connect to one or two seed nodes because once it connects,
186 // it'll get a pile of addresses with newer timestamps.
187 // Seed nodes are given a random 'last seen time' of between one and two
188 // weeks ago.
189 const int64_t nOneWeek = 7*24*60*60;
190 std::vector<CAddress> vSeedsOut;
191 FastRandomContext rng;
192 CDataStream s(vSeedsIn, SER_NETWORK, PROTOCOL_VERSION | ADDRV2_FORMAT);
193 while (!s.eof()) {
194 CService endpoint;
195 s >> endpoint;
196 CAddress addr{endpoint, GetDesirableServiceFlags(NODE_NONE)};
197 addr.nTime = GetTime() - rng.randrange(nOneWeek) - nOneWeek;
198 LogPrint(BCLog::NET, "Added hardcoded seed: %s\n", addr.ToString());
199 vSeedsOut.push_back(addr);
200 }
201 return vSeedsOut;
202}
203
204// get best local address for a particular peer as a CAddress
205// Otherwise, return the unroutable 0.0.0.0 but filled in with

Callers 1

ThreadOpenConnectionsMethod · 0.85

Calls 6

GetDesirableServiceFlagsFunction · 0.85
GetTimeFunction · 0.85
randrangeMethod · 0.80
eofMethod · 0.45
ToStringMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected