PRCYCoin  2.0.0.7rc1
P2P Digital Currency
addrman.h
Go to the documentation of this file.
1 // Copyright (c) 2012 Pieter Wuille
2 // Copyright (c) 2012-2015 The Bitcoin developers
3 // Copyright (c) 2017-2020 The PIVX developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef BITCOIN_ADDRMAN_H
8 #define BITCOIN_ADDRMAN_H
9 
10 #include "netaddress.h"
11 #include "protocol.h"
12 #include "random.h"
13 #include "sync.h"
14 #include "timedata.h"
15 #include "util.h"
16 
17 #include <map>
18 #include <set>
19 #include <stdint.h>
20 #include <vector>
21 
25 class CAddrInfo : public CAddress
26 {
27 
28 
29 public:
31  int64_t nLastTry;
32 
35 
36 private:
39 
41  int64_t nLastSuccess;
42 
44  int nAttempts;
45 
47  int nRefCount;
48 
50  bool fInTried;
51 
54 
55  friend class CAddrMan;
56 
57 public:
59 
60  template <typename Stream, typename Operation>
61  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
62  {
63  READWRITE(*(CAddress*)this);
67  }
68 
69  void Init()
70  {
71  nLastSuccess = 0;
72  nLastTry = 0;
74  nAttempts = 0;
75  nRefCount = 0;
76  fInTried = false;
77  nRandomPos = -1;
78  }
79 
80  CAddrInfo(const CAddress& addrIn, const CNetAddr& addrSource) : CAddress(addrIn), source(addrSource)
81  {
82  Init();
83  }
84 
86  {
87  Init();
88  }
89 
91  int GetTriedBucket(const uint256& nKey) const;
92 
94  int GetNewBucket(const uint256& nKey, const CNetAddr& src) const;
95 
97  int GetNewBucket(const uint256& nKey) const
98  {
99  return GetNewBucket(nKey, source);
100  }
101 
103  int GetBucketPosition(const uint256& nKey, bool fNew, int nBucket) const;
104 
106  bool IsTerrible(int64_t nNow = GetAdjustedTime()) const;
107 
109  double GetChance(int64_t nNow = GetAdjustedTime()) const;
110 };
111 
138 #define ADDRMAN_TRIED_BUCKET_COUNT_LOG2 8
140 
142 #define ADDRMAN_NEW_BUCKET_COUNT_LOG2 10
143 
145 #define ADDRMAN_BUCKET_SIZE_LOG2 6
146 
148 #define ADDRMAN_TRIED_BUCKETS_PER_GROUP 8
149 
151 #define ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP 64
152 
154 #define ADDRMAN_NEW_BUCKETS_PER_ADDRESS 8
155 
157 #define ADDRMAN_HORIZON_DAYS 30
158 
160 #define ADDRMAN_RETRIES 3
161 
163 #define ADDRMAN_MAX_FAILURES 10
164 
166 #define ADDRMAN_MIN_FAIL_DAYS 7
167 
169 #define ADDRMAN_GETADDR_MAX_PCT 23
170 
172 #define ADDRMAN_GETADDR_MAX 2500
173 
175 #define ADDRMAN_TRIED_BUCKET_COUNT (1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2)
176 #define ADDRMAN_NEW_BUCKET_COUNT (1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2)
177 #define ADDRMAN_BUCKET_SIZE (1 << ADDRMAN_BUCKET_SIZE_LOG2)
178 
182 class CAddrMan
183 {
184 private:
187 
189  int nIdCount;
190 
192  std::map<int, CAddrInfo> mapInfo;
193 
195  std::map<CNetAddr, int> mapAddr;
196 
198  std::vector<int> vRandom;
199 
200  // number of "tried" entries
201  int nTried;
202 
205 
207  int nNew;
208 
211 
213  int64_t nLastGood;
214 
215 protected:
218 
221 
223  CAddrInfo* Find(const CNetAddr& addr, int* pnId = NULL);
224 
227  CAddrInfo* Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId = NULL);
228 
230  void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2);
231 
233  void MakeTried(CAddrInfo& info, int nId);
234 
236  void Delete(int nId);
237 
239  void ClearNew(int nUBucket, int nUBucketPos);
240 
242  void Good_(const CService& addr, int64_t nTime);
243 
245  bool Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty);
246 
248  void Attempt_(const CService& addr, bool fCountFailure, int64_t nTime);
249 
251  CAddrInfo Select_(bool newOnly);
252 
254  virtual int RandomInt(int nMax);
255 
256 #ifdef DEBUG_ADDRMAN
257  int Check_();
259 #endif
260 
262  void GetAddr_(std::vector<CAddress>& vAddr);
263 
265  void Connected_(const CService& addr, int64_t nTime);
266 
268  void SetServices_(const CService& addr, ServiceFlags nServices);
269 
270 public:
300  template <typename Stream>
301  void Serialize(Stream& s, int nType, int nVersionDummy) const
302  {
303  LOCK(cs);
304 
305  unsigned char nVersion = 1;
306  s << nVersion;
307  s << ((unsigned char)32);
308  s << nKey;
309  s << nNew;
310  s << nTried;
311 
312  int nUBuckets = ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30);
313  s << nUBuckets;
314  std::map<int, int> mapUnkIds;
315  int nIds = 0;
316  for (std::map<int, CAddrInfo>::const_iterator it = mapInfo.begin(); it != mapInfo.end(); it++) {
317  mapUnkIds[(*it).first] = nIds;
318  const CAddrInfo& info = (*it).second;
319  if (info.nRefCount) {
320  assert(nIds != nNew); // this means nNew was wrong, oh ow
321  s << info;
322  nIds++;
323  }
324  }
325  nIds = 0;
326  for (std::map<int, CAddrInfo>::const_iterator it = mapInfo.begin(); it != mapInfo.end(); it++) {
327  const CAddrInfo& info = (*it).second;
328  if (info.fInTried) {
329  assert(nIds != nTried); // this means nTried was wrong, oh ow
330  s << info;
331  nIds++;
332  }
333  }
334  for (int bucket = 0; bucket < ADDRMAN_NEW_BUCKET_COUNT; bucket++) {
335  int nSize = 0;
336  for (int i = 0; i < ADDRMAN_BUCKET_SIZE; i++) {
337  if (vvNew[bucket][i] != -1)
338  nSize++;
339  }
340  s << nSize;
341  for (int i = 0; i < ADDRMAN_BUCKET_SIZE; i++) {
342  if (vvNew[bucket][i] != -1) {
343  int nIndex = mapUnkIds[vvNew[bucket][i]];
344  s << nIndex;
345  }
346  }
347  }
348  }
349 
350  template <typename Stream>
351  void Unserialize(Stream& s, int nType, int nVersionDummy)
352  {
353  LOCK(cs);
354 
355  Clear();
356 
357  unsigned char nVersion;
358  s >> nVersion;
359  unsigned char nKeySize;
360  s >> nKeySize;
361  if (nKeySize != 32) throw std::ios_base::failure("Incorrect keysize in addrman deserialization");
362  s >> nKey;
363  s >> nNew;
364  s >> nTried;
365  int nUBuckets = 0;
366  s >> nUBuckets;
367  if (nVersion != 0) {
368  nUBuckets ^= (1 << 30);
369  }
370 
371  // Deserialize entries from the new table.
372  for (int n = 0; n < nNew; n++) {
373  CAddrInfo& info = mapInfo[n];
374  s >> info;
375  mapAddr[info] = n;
376  info.nRandomPos = vRandom.size();
377  vRandom.push_back(n);
378  if (nVersion != 1 || nUBuckets != ADDRMAN_NEW_BUCKET_COUNT) {
379  // In case the new table data cannot be used (nVersion unknown, or bucket count wrong),
380  // immediately try to give them a reference based on their primary source address.
381  int nUBucket = info.GetNewBucket(nKey);
382  int nUBucketPos = info.GetBucketPosition(nKey, true, nUBucket);
383  if (vvNew[nUBucket][nUBucketPos] == -1) {
384  vvNew[nUBucket][nUBucketPos] = n;
385  info.nRefCount++;
386  }
387  }
388  }
389  nIdCount = nNew;
390 
391  // Deserialize entries from the tried table.
392  int nLost = 0;
393  for (int n = 0; n < nTried; n++) {
394  CAddrInfo info;
395  s >> info;
396  int nKBucket = info.GetTriedBucket(nKey);
397  int nKBucketPos = info.GetBucketPosition(nKey, false, nKBucket);
398  if (vvTried[nKBucket][nKBucketPos] == -1) {
399  info.nRandomPos = vRandom.size();
400  info.fInTried = true;
401  vRandom.push_back(nIdCount);
402  mapInfo[nIdCount] = info;
403  mapAddr[info] = nIdCount;
404  vvTried[nKBucket][nKBucketPos] = nIdCount;
405  nIdCount++;
406  } else {
407  nLost++;
408  }
409  }
410  nTried -= nLost;
411 
412  // Deserialize positions in the new table (if possible).
413  for (int bucket = 0; bucket < nUBuckets; bucket++) {
414  int nSize = 0;
415  s >> nSize;
416  for (int n = 0; n < nSize; n++) {
417  int nIndex = 0;
418  s >> nIndex;
419  if (nIndex >= 0 && nIndex < nNew) {
420  CAddrInfo& info = mapInfo[nIndex];
421  int nUBucketPos = info.GetBucketPosition(nKey, true, bucket);
422  if (nVersion == 1 && nUBuckets == ADDRMAN_NEW_BUCKET_COUNT && vvNew[bucket][nUBucketPos] == -1 && info.nRefCount < ADDRMAN_NEW_BUCKETS_PER_ADDRESS) {
423  info.nRefCount++;
424  vvNew[bucket][nUBucketPos] = nIndex;
425  }
426  }
427  }
428  }
429 
430  // Prune new entries with refcount 0 (as a result of collisions).
431  int nLostUnk = 0;
432  for (std::map<int, CAddrInfo>::const_iterator it = mapInfo.begin(); it != mapInfo.end();) {
433  if (it->second.fInTried == false && it->second.nRefCount == 0) {
434  std::map<int, CAddrInfo>::const_iterator itCopy = it++;
435  Delete(itCopy->first);
436  nLostUnk++;
437  } else {
438  it++;
439  }
440  }
441  if (nLost + nLostUnk > 0) {
442  LogPrint(BCLog::ADDRMAN, "addrman lost %i new and %i tried addresses due to collisions\n", nLostUnk, nLost);
443  }
444 
445  Check();
446  }
447 
448  unsigned int GetSerializeSize(int nType, int nVersion) const
449  {
450  return (CSizeComputer(nType, nVersion) << *this).size();
451  }
452 
453  void Clear()
454  {
455  std::vector<int>().swap(vRandom);
456  nKey = GetRandHash();
457  for (size_t bucket = 0; bucket < ADDRMAN_NEW_BUCKET_COUNT; bucket++) {
458  for (size_t entry = 0; entry < ADDRMAN_BUCKET_SIZE; entry++) {
459  vvNew[bucket][entry] = -1;
460  }
461  }
462  for (size_t bucket = 0; bucket < ADDRMAN_TRIED_BUCKET_COUNT; bucket++) {
463  for (size_t entry = 0; entry < ADDRMAN_BUCKET_SIZE; entry++) {
464  vvTried[bucket][entry] = -1;
465  }
466  }
467 
468  nIdCount = 0;
469  nTried = 0;
470  nNew = 0;
471  nLastGood = 1; //Initially at 1 so that "never" is strictly worse.
472  }
473 
475  {
476  Clear();
477  }
478 
480  {
481  nKey = UINT256_ZERO;
482  }
483 
485  int size()
486  {
487  LOCK(cs); // TODO: Cache this in an atomic to avoid this overhead
488  return vRandom.size();
489  }
490 
492  void Check()
493  {
494 #ifdef DEBUG_ADDRMAN
495  {
496  LOCK(cs);
497  int err;
498  if ((err = Check_()))
499  LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);
500  }
501 #endif
502  }
503 
505  bool Add(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty = 0)
506  {
507  LOCK(cs);
508  bool fRet = false;
509  Check();
510  fRet |= Add_(addr, source, nTimePenalty);
511  Check();
512  if (fRet)
513  LogPrint(BCLog::ADDRMAN, "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort(), source.ToString(), nTried, nNew);
514  return fRet;
515  }
516 
518  bool Add(const std::vector<CAddress>& vAddr, const CNetAddr& source, int64_t nTimePenalty = 0)
519  {
520  LOCK(cs);
521  int nAdd = 0;
522  Check();
523  for (std::vector<CAddress>::const_iterator it = vAddr.begin(); it != vAddr.end(); it++)
524  nAdd += Add_(*it, source, nTimePenalty) ? 1 : 0;
525  Check();
526  if (nAdd)
527  LogPrint(BCLog::ADDRMAN, "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString(), nTried, nNew);
528  return nAdd > 0;
529  }
530 
532  void Good(const CService& addr, int64_t nTime = GetAdjustedTime())
533  {
534  LOCK(cs);
535  Check();
536  Good_(addr, nTime);
537  Check();
538  }
539 
541  void Attempt(const CService& addr, bool fCountFailure, int64_t nTime = GetAdjustedTime())
542  {
543  LOCK(cs);
544  Check();
545  Attempt_(addr, fCountFailure, nTime);
546  Check();
547  }
548 
553  CAddrInfo Select(bool newOnly = false)
554  {
555  CAddrInfo addrRet;
556  {
557  LOCK(cs);
558  Check();
559  addrRet = Select_(newOnly);
560  Check();
561  }
562  return addrRet;
563  }
564 
566  std::vector<CAddress> GetAddr()
567  {
568  Check();
569  std::vector<CAddress> vAddr;
570  {
571  LOCK(cs);
572  GetAddr_(vAddr);
573  }
574  Check();
575  return vAddr;
576  }
577 
579  void Connected(const CService& addr, int64_t nTime = GetAdjustedTime())
580  {
581  LOCK(cs);
582  Check();
583  Connected_(addr, nTime);
584  Check();
585  }
586 
587  void SetServices(const CService& addr, ServiceFlags nServices)
588  {
589  LOCK(cs);
590  Check();
591  SetServices_(addr, nServices);
592  Check();
593  }
594 };
595 
596 #endif // BITCOIN_ADDRMAN_H
CAddrMan::~CAddrMan
~CAddrMan()
Definition: addrman.h:479
CService
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:133
CAddrMan::nKey
uint256 nKey
secret key to randomize bucket select with
Definition: addrman.h:217
UINT256_ZERO
const uint256 UINT256_ZERO
constant uint256 instances
Definition: uint256.h:129
CAddrMan::SetServices_
void SetServices_(const CService &addr, ServiceFlags nServices)
Update an entry's service bits.
Definition: addrman.cpp:513
CAddrInfo::CAddrInfo
CAddrInfo()
Definition: addrman.h:85
CAddrInfo::source
CNetAddr source
where knowledge about this address first came from
Definition: addrman.h:38
CAddrMan::Create
CAddrInfo * Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId=NULL)
find an entry, creating it if necessary.
Definition: addrman.cpp:88
CAddrMan::Select_
CAddrInfo Select_(bool newOnly)
Select an address to connect to, if newOnly is set to true, only the new table is selected from.
Definition: addrman.cpp:344
CAddrMan::RandomInt
virtual int RandomInt(int nMax)
Wraps GetRandInt to allow tests to override RandomInt and make it determinismistic.
Definition: addrman.cpp:509
CAddrMan::ClearNew
void ClearNew(int nUBucket, int nUBucketPos)
Clear a position in a "new" table. This is the only place where entries are actually deleted.
Definition: addrman.cpp:134
ADDRMAN_NEW_BUCKETS_PER_ADDRESS
#define ADDRMAN_NEW_BUCKETS_PER_ADDRESS
in how many buckets for entries with new addresses a single address may occur
Definition: addrman.h:154
CAddrInfo::Init
void Init()
Definition: addrman.h:69
sync.h
CAddrMan::Add
bool Add(const CAddress &addr, const CNetAddr &source, int64_t nTimePenalty=0)
Add a single address.
Definition: addrman.h:505
CAddrMan::Unserialize
void Unserialize(Stream &s, int nType, int nVersionDummy)
Definition: addrman.h:351
timedata.h
CNetAddr
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
Definition: netaddress.h:30
source
const char * source
Definition: rpcconsole.cpp:62
CAddrInfo::GetTriedBucket
int GetTriedBucket(const uint256 &nKey) const
Calculate in which "tried" bucket this entry belongs.
Definition: addrman.cpp:12
CAddrInfo::nLastSuccess
int64_t nLastSuccess
last successful connection by us
Definition: addrman.h:41
CAddrInfo::GetChance
double GetChance(int64_t nNow=GetAdjustedTime()) const
Calculate the relative chance this entry should be given when selecting nodes to connect to.
Definition: addrman.cpp:53
CAddrMan::Select
CAddrInfo Select(bool newOnly=false)
Choose an address to connect to.
Definition: addrman.h:553
AnnotatedMixin< std::recursive_mutex >
ServiceFlags
ServiceFlags
nServices flags
Definition: protocol.h:296
CAddrInfo::IsTerrible
bool IsTerrible(int64_t nNow=GetAdjustedTime()) const
Determine whether the statistics about this entry are bad enough so that it can just be deleted.
Definition: addrman.cpp:33
CService::ToStringIPPort
std::string ToStringIPPort() const
Definition: netaddress.cpp:559
CAddrMan::vvNew
int vvNew[ADDRMAN_NEW_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE]
list of "new" buckets
Definition: addrman.h:210
CAddrMan::cs
RecursiveMutex cs
critical section to protect the inner data structures
Definition: addrman.h:186
CAddrInfo::GetNewBucket
int GetNewBucket(const uint256 &nKey) const
Calculate in which "new" bucket this entry belongs, using its default source.
Definition: addrman.h:97
CAddrMan::GetAddr
std::vector< CAddress > GetAddr()
Return a bunch of addresses, selected at random.
Definition: addrman.h:566
CAddrMan::GetSerializeSize
unsigned int GetSerializeSize(int nType, int nVersion) const
Definition: addrman.h:448
CAddrMan::nLastGood
int64_t nLastGood
last time Good was called (memory only)
Definition: addrman.h:213
CAddrInfo
Extended statistics about a CAddress.
Definition: addrman.h:25
CAddrInfo::SerializationOp
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
Definition: addrman.h:61
CAddrInfo::nLastCountAttempt
int64_t nLastCountAttempt
last counted attempt (memory only)
Definition: addrman.h:34
protocol.h
random.h
CAddrMan::Find
CAddrInfo * Find(const CNetAddr &addr, int *pnId=NULL)
Find an entry.
Definition: addrman.cpp:75
CSizeComputer
Definition: serialize.h:911
ADDRMAN_BUCKET_SIZE
#define ADDRMAN_BUCKET_SIZE
Definition: addrman.h:177
CAddrInfo::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition: addrman.h:58
ADDRMAN_TRIED_BUCKET_COUNT
#define ADDRMAN_TRIED_BUCKET_COUNT
Convenience.
Definition: addrman.h:175
CAddrMan::mapAddr
std::map< CNetAddr, int > mapAddr
find an nId based on its network address
Definition: addrman.h:195
netaddress.h
CAddrMan::nTried
int nTried
Definition: addrman.h:201
CAddrInfo::CAddrInfo
CAddrInfo(const CAddress &addrIn, const CNetAddr &addrSource)
Definition: addrman.h:80
CAddrMan::SwapRandom
void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2)
Swap two elements in vRandom.
Definition: addrman.cpp:100
CAddrInfo::nRefCount
int nRefCount
reference count in new sets (memory only)
Definition: addrman.h:47
LogPrintf
#define LogPrintf(...)
Definition: logging.h:147
CAddrMan::insecure_rand
FastRandomContext insecure_rand
Source of random numbers for randomization in inner loops.
Definition: addrman.h:220
GetRandHash
uint256 GetRandHash()
Definition: random.cpp:371
CAddrInfo::nRandomPos
int nRandomPos
position in vRandom
Definition: addrman.h:53
CAddrMan::MakeTried
void MakeTried(CAddrInfo &info, int nId)
Move an entry from the "new" table(s) to the "tried" table.
Definition: addrman.cpp:149
CAddrInfo::nLastTry
int64_t nLastTry
last try whatsoever by us (memory only)
Definition: addrman.h:31
CAddrMan::nIdCount
int nIdCount
last used nId
Definition: addrman.h:189
CAddrInfo::GetBucketPosition
int GetBucketPosition(const uint256 &nKey, bool fNew, int nBucket) const
Calculate in which position of a bucket to store this entry.
Definition: addrman.cpp:27
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
CAddrMan::vRandom
std::vector< int > vRandom
randomly-ordered vector of all nIds
Definition: addrman.h:198
LogPrint
#define LogPrint(category,...)
Definition: logging.h:162
ADDRMAN_NEW_BUCKET_COUNT
#define ADDRMAN_NEW_BUCKET_COUNT
Definition: addrman.h:176
CAddrMan::Check
void Check()
Consistency check.
Definition: addrman.h:492
CAddrMan
Stochastical (IP) address manager.
Definition: addrman.h:182
CAddrInfo::GetNewBucket
int GetNewBucket(const uint256 &nKey, const CNetAddr &src) const
Calculate in which "new" bucket this entry belongs, given a certain source.
Definition: addrman.cpp:19
GetAdjustedTime
int64_t GetAdjustedTime()
Definition: timedata.cpp:30
CAddress
A CService with information about it as peer.
Definition: protocol.h:323
READWRITE
#define READWRITE(obj)
Definition: serialize.h:164
CAddrInfo::nAttempts
int nAttempts
connection attempts since last successful attempt
Definition: addrman.h:44
CAddrMan::Delete
void Delete(int nId)
Delete an entry. It must not be in tried, and have refcount 0.
Definition: addrman.cpp:120
LOCK
#define LOCK(cs)
Definition: sync.h:182
CAddrMan::Serialize
void Serialize(Stream &s, int nType, int nVersionDummy) const
serialized format:
Definition: addrman.h:301
CAddrMan::Connected_
void Connected_(const CService &addr, int64_t nTime)
Mark an entry as currently-connected-to.
Definition: addrman.cpp:489
CAddrMan::Connected
void Connected(const CService &addr, int64_t nTime=GetAdjustedTime())
Mark an entry as currently-connected-to.
Definition: addrman.h:579
CAddrMan::Clear
void Clear()
Definition: addrman.h:453
CAddrMan::GetAddr_
void GetAddr_(std::vector< CAddress > &vAddr)
Select several addresses at once.
Definition: addrman.cpp:468
CAddrMan::CAddrMan
CAddrMan()
Definition: addrman.h:474
CAddrMan::SetServices
void SetServices(const CService &addr, ServiceFlags nServices)
Definition: addrman.h:587
CAddrMan::size
int size()
Return the number of (unique) addresses in all tables.
Definition: addrman.h:485
BCLog::ADDRMAN
@ ADDRMAN
Definition: logging.h:49
CAddrInfo::fInTried
bool fInTried
in tried set? (memory only)
Definition: addrman.h:50
CAddrMan::Good_
void Good_(const CService &addr, int64_t nTime)
Mark an entry "good", possibly moving it from "new" to "tried".
Definition: addrman.cpp:197
CAddrMan::Good
void Good(const CService &addr, int64_t nTime=GetAdjustedTime())
Mark an entry as accessible.
Definition: addrman.h:532
CAddrMan::nNew
int nNew
number of (unique) "new" entries
Definition: addrman.h:207
CAddrMan::mapInfo
std::map< int, CAddrInfo > mapInfo
table with information about all nIds
Definition: addrman.h:192
CAddrMan::Add
bool Add(const std::vector< CAddress > &vAddr, const CNetAddr &source, int64_t nTimePenalty=0)
Add multiple addresses.
Definition: addrman.h:518
CAddrMan::vvTried
int vvTried[ADDRMAN_TRIED_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE]
list of "tried" buckets
Definition: addrman.h:204
util.h
CAddrMan::Add_
bool Add_(const CAddress &addr, const CNetAddr &source, int64_t nTimePenalty)
Add an entry to the "new" table.
Definition: addrman.cpp:249
CAddrMan::Attempt
void Attempt(const CService &addr, bool fCountFailure, int64_t nTime=GetAdjustedTime())
Mark an entry as connection attempted to.
Definition: addrman.h:541
FastRandomContext
Fast randomness source.
Definition: random.h:44
CAddrMan::Attempt_
void Attempt_(const CService &addr, bool fCountFailure, int64_t nTime)
Mark an entry as attempted to connect.
Definition: addrman.cpp:322