52 size_t rnd = rand() % tot;
54 if (rnd <
unkId.size()) {
55 std::set<int>::iterator it =
unkId.end();
88 int blocks, uint64_t services,
bool checkpointVerified) {
134 if (
goodId.count(
id) == 1) {
149 time_t bantime =
banned[ipp];
151 (bantime < time(
nullptr) &&
158 if (ipToId.count(ipp)) {
160 if (addr.nTime >
NodeSeconds{std::chrono::seconds{ai.lastTry}} ||
162 ai.
lastTry = TicksSinceEpoch<std::chrono::seconds>(addr.nTime);
176 ai.
lastTry = TicksSinceEpoch<std::chrono::seconds>(addr.nTime);
189 uint32_t max,
const bool *nets) {
192 if (
ourId.size() == 0) {
193 if (
unkId.size() == 0) {
202 (
idToInfo[
id].services & requestedFlags) == requestedFlags) {
208 std::vector<int> goodIdFiltered;
210 if ((
idToInfo[
id].services & requestedFlags) == requestedFlags) {
211 goodIdFiltered.push_back(
id);
215 if (!goodIdFiltered.size()) {
219 if (max > goodIdFiltered.size() / 2) {
220 max = goodIdFiltered.size() / 2;
228 while (ids.size() < max) {
229 ids.insert(goodIdFiltered[rand() % goodIdFiltered.size()]);
232 for (
auto &
id : ids) {
void Bad_(const CService &ip, int ban)
void GetIPs_(std::set< CNetAddr > &ips, uint64_t requestedFlags, uint32_t max, const bool *nets)
void Good_(const CService &ip, int clientV, std::string clientSV, int blocks, uint64_t services, bool checkpointVerified)
std::map< CService, int > ipToId
std::map< CService, int64_t > banned
std::map< int, SeederAddrInfo > idToInfo
bool Get_(CServiceResult &ip)
void Add_(const CAddress &addr, bool force)
int Lookup_(const CService &ip)
void Update(bool good, int64_t age, double tau)
A CService with information about it as peer.
NodeSeconds nTime
Always included in serialization, except in the network format on INIT_PROTO_VERSION.
enum Network GetNetwork() const
A combination of a network address (CNetAddr) and a (TCP) port.
int64_t GetIgnoreTime() const
int64_t GetBanTime() const
std::string clientSubVersion
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds