Convert the pnSeeds6 array into usable address objects.
| 157 | |
| 158 | //! Convert the pnSeeds6 array into usable address objects. |
| 159 | static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn) |
| 160 | { |
| 161 | // It'll only connect to one or two seed nodes because once it connects, |
| 162 | // it'll get a pile of addresses with newer timestamps. |
| 163 | // Seed nodes are given a random 'last seen time' of between one and two |
| 164 | // weeks ago. |
| 165 | const int64_t nOneWeek = 7*24*60*60; |
| 166 | std::vector<CAddress> vSeedsOut; |
| 167 | vSeedsOut.reserve(vSeedsIn.size()); |
| 168 | for (std::vector<SeedSpec6>::const_iterator i(vSeedsIn.begin()); i != vSeedsIn.end(); ++i) |
| 169 | { |
| 170 | struct in6_addr ip; |
| 171 | memcpy(&ip, i->addr, sizeof(ip)); |
| 172 | CAddress addr(CService(ip, i->port)); |
| 173 | addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek; |
| 174 | vSeedsOut.push_back(addr); |
| 175 | } |
| 176 | return vSeedsOut; |
| 177 | } |
| 178 | |
| 179 | // get best local address for a particular peer as a CAddress |
| 180 | // Otherwise, return the unroutable 0.0.0.0 but filled in with |