53 size_t rnd = rand() % tot;
55 if (rnd <
unkId.size()) {
56 std::set<int>::iterator it =
unkId.end();
90 int blocks, uint64_t services) {
136 if (
goodId.count(
id) == 1) {
152 time_t bantime =
banned[ipp];
154 (bantime < time(
nullptr) &&
161 if (ipToId.count(ipp)) {
163 if (addr.nTime >
NodeSeconds{std::chrono::seconds{ai.lastTry}} ||
165 ai.
lastTry = TicksSinceEpoch<std::chrono::seconds>(addr.nTime);
179 ai.
lastTry = TicksSinceEpoch<std::chrono::seconds>(addr.nTime);
193 uint32_t max,
const bool *nets) {
196 if (
ourId.size() == 0) {
197 if (
unkId.size() == 0) {
206 (
idToInfo[
id].services & requestedFlags) == requestedFlags) {
212 std::vector<int> goodIdFiltered;
214 if ((
idToInfo[
id].services & requestedFlags) == requestedFlags) {
215 goodIdFiltered.push_back(
id);
219 if (!goodIdFiltered.size()) {
223 if (max > goodIdFiltered.size() / 2) {
224 max = goodIdFiltered.size() / 2;
232 while (ids.size() < max) {
233 ids.insert(goodIdFiltered[rand() % goodIdFiltered.size()]);
236 for (
auto &
id : ids) {
void Bad_(const CService &ip, int ban)
void Good_(const CService &ip, int clientV, std::string clientSV, int blocks, uint64_t services)
void GetIPs_(std::set< CNetAddr > &ips, uint64_t requestedFlags, uint32_t max, const bool *nets)
std::map< CService, int > ipToId
std::map< CService, int64_t > banned
std::map< int, SeederAddrInfo > idToInfo
void Add_(const CAddress &addr, bool force)
bool Get_(CServiceResult &ip, int &wait)
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
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds