Convert the serialized seeds into usable address objects.
| 181 | |
| 182 | //! Convert the serialized seeds into usable address objects. |
| 183 | static 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 |
no test coverage detected