![]() |
Dash Core
0.12.2.1
P2P Digital Currency
|
#include <addrman.h>
Public Member Functions | |
template<typename Stream > | |
void | Serialize (Stream &s, int nType, int nVersionDummy) const |
template<typename Stream > | |
void | Unserialize (Stream &s, int nType, int nVersionDummy) |
unsigned int | GetSerializeSize (int nType, int nVersion) const |
void | Clear () |
CAddrMan () | |
~CAddrMan () | |
size_t | size () const |
Return the number of (unique) addresses in all tables. More... | |
void | Check () |
Consistency check. More... | |
bool | Add (const CAddress &addr, const CNetAddr &source, int64_t nTimePenalty=0) |
Add a single address. More... | |
bool | Add (const std::vector< CAddress > &vAddr, const CNetAddr &source, int64_t nTimePenalty=0) |
Add multiple addresses. More... | |
void | Good (const CService &addr, int64_t nTime=GetAdjustedTime()) |
Mark an entry as accessible. More... | |
void | Attempt (const CService &addr, int64_t nTime=GetAdjustedTime()) |
Mark an entry as connection attempted to. More... | |
CAddrInfo | Select (bool newOnly=false) |
std::vector< CAddress > | GetAddr () |
Return a bunch of addresses, selected at random. More... | |
void | Connected (const CService &addr, int64_t nTime=GetAdjustedTime()) |
Mark an entry as currently-connected-to. More... | |
void | SetServices (const CService &addr, ServiceFlags nServices) |
Protected Member Functions | |
CAddrInfo * | Find (const CNetAddr &addr, int *pnId=NULL) |
Find an entry. More... | |
CAddrInfo * | Create (const CAddress &addr, const CNetAddr &addrSource, int *pnId=NULL) |
void | SwapRandom (unsigned int nRandomPos1, unsigned int nRandomPos2) |
Swap two elements in vRandom. More... | |
void | MakeTried (CAddrInfo &info, int nId) |
Move an entry from the "new" table(s) to the "tried" table. More... | |
void | Delete (int nId) |
Delete an entry. It must not be in tried, and have refcount 0. More... | |
void | ClearNew (int nUBucket, int nUBucketPos) |
Clear a position in a "new" table. This is the only place where entries are actually deleted. More... | |
void | Good_ (const CService &addr, int64_t nTime) |
Mark an entry "good", possibly moving it from "new" to "tried". More... | |
bool | Add_ (const CAddress &addr, const CNetAddr &source, int64_t nTimePenalty) |
Add an entry to the "new" table. More... | |
void | Attempt_ (const CService &addr, int64_t nTime) |
Mark an entry as attempted to connect. More... | |
CAddrInfo | Select_ (bool newOnly) |
Select an address to connect to, if newOnly is set to true, only the new table is selected from. More... | |
virtual int | RandomInt (int nMax) |
Wraps GetRandInt to allow tests to override RandomInt and make it determinismistic. More... | |
void | GetAddr_ (std::vector< CAddress > &vAddr) |
Select several addresses at once. More... | |
void | Connected_ (const CService &addr, int64_t nTime) |
Mark an entry as currently-connected-to. More... | |
void | SetServices_ (const CService &addr, ServiceFlags nServices) |
Update an entry's service bits. More... | |
Protected Attributes | |
uint256 | nKey |
secret key to randomize bucket select with More... | |
Private Attributes | |
CCriticalSection | cs |
critical section to protect the inner data structures More... | |
int | nIdCount |
last used nId More... | |
std::map< int, CAddrInfo > | mapInfo |
table with information about all nIds More... | |
std::map< CNetAddr, int > | mapAddr |
find an nId based on its network address More... | |
std::vector< int > | vRandom |
randomly-ordered vector of all nIds More... | |
int | nTried |
int | vvTried [ADDRMAN_TRIED_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE] |
list of "tried" buckets More... | |
int | nNew |
number of (unique) "new" entries More... | |
int | vvNew [ADDRMAN_NEW_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE] |
list of "new" buckets More... | |
|
inline |
Add a single address.
Definition at line 487 of file addrman.h.
Referenced by CConnman::AddNewAddress(), CConnman::AddNewAddresses(), CConnman::ThreadDNSAddressSeed(), and CConnman::ThreadOpenConnections().
|
inline |
Mark an entry as connection attempted to.
Definition at line 529 of file addrman.h.
Referenced by CConnman::ConnectNode().
|
protected |
Mark an entry as attempted to connect.
Definition at line 313 of file addrman.cpp.
Referenced by Attempt().
|
inline |
Consistency check.
Definition at line 474 of file addrman.h.
Referenced by Add(), Attempt(), Connected(), GetAddr(), Good(), Select(), SetServices(), and Unserialize().
|
inline |
Definition at line 437 of file addrman.h.
Referenced by CAddrMan(), CAddrDB::Read(), CConnman::Start(), and Unserialize().
|
protected |
Clear a position in a "new" table. This is the only place where entries are actually deleted.
Definition at line 133 of file addrman.cpp.
Referenced by Add_(), and MakeTried().
|
inline |
Mark an entry as currently-connected-to.
Definition at line 568 of file addrman.h.
Referenced by CConnman::DeleteNode().
|
protected |
Mark an entry as currently-connected-to.
Definition at line 478 of file addrman.cpp.
Referenced by Connected().
|
protected |
find an entry, creating it if necessary. nTime and nServices of the found node are updated, if necessary.
Definition at line 87 of file addrman.cpp.
Referenced by Add_().
|
protected |
Delete an entry. It must not be in tried, and have refcount 0.
Definition at line 119 of file addrman.cpp.
Referenced by Add_(), ClearNew(), and Unserialize().
Find an entry.
Definition at line 74 of file addrman.cpp.
Referenced by Add_(), Attempt_(), Connected_(), Good_(), and SetServices_().
|
inline |
Return a bunch of addresses, selected at random.
Definition at line 555 of file addrman.h.
Referenced by CConnman::GetAddresses().
|
protected |
Select several addresses at once.
Definition at line 457 of file addrman.cpp.
Referenced by GetAddr().
|
inline |
|
inline |
Mark an entry as accessible.
Definition at line 518 of file addrman.h.
Referenced by CConnman::MarkAddressGood().
|
protected |
Mark an entry "good", possibly moving it from "new" to "tried".
Definition at line 196 of file addrman.cpp.
Referenced by Good().
|
protected |
Move an entry from the "new" table(s) to the "tried" table.
Definition at line 148 of file addrman.cpp.
Referenced by Good_().
|
protectedvirtual |
Wraps GetRandInt to allow tests to override RandomInt and make it determinismistic.
Definition at line 516 of file addrman.cpp.
Referenced by Add_(), GetAddr_(), Good_(), and Select_().
|
inline |
Choose an address to connect to.
Definition at line 542 of file addrman.h.
Referenced by CConnman::ThreadOpenConnections().
|
protected |
Select an address to connect to, if newOnly is set to true, only the new table is selected from.
Definition at line 332 of file addrman.cpp.
Referenced by Select().
|
inline |
serialized format:
2**30 is xorred with the number of buckets to make addrman deserializer v0 detect it as incompatible. This is necessary because it did not check the version number on deserialization.
Notice that vvTried, mapAddr and vVector are never encoded explicitly; they are instead reconstructed from the other information.
vvNew is serialized, but only used if ADDRMAN_UNKNOWN_BUCKET_COUNT didn't change, otherwise it is reconstructed as well.
This format is more complex, but significantly smaller (at most 1.5 MiB), and supports changes to the ADDRMAN_ parameters without breaking the on-disk structure.
We don't use ADD_SERIALIZE_METHODS since the serialization and deserialization code has very little in common.
|
inline |
Definition at line 578 of file addrman.h.
Referenced by CConnman::SetServices().
|
protected |
Update an entry's service bits.
Definition at line 498 of file addrman.cpp.
Referenced by SetServices().
|
inline |
Return the number of (unique) addresses in all tables.
Definition at line 468 of file addrman.h.
Referenced by CConnman::DumpAddresses(), CConnman::GetAddressCount(), Select_(), CConnman::Start(), CConnman::ThreadDNSAddressSeed(), and CConnman::ThreadOpenConnections().
|
protected |
Swap two elements in vRandom.
Definition at line 99 of file addrman.cpp.
Referenced by Delete(), and GetAddr_().
|
inline |
|
mutableprivate |
critical section to protect the inner data structures
Definition at line 176 of file addrman.h.
Referenced by Add(), Attempt(), Check(), Connected(), GetAddr(), Good(), Select(), Serialize(), SetServices(), and Unserialize().
|
private |
|
private |
table with information about all nIds
Definition at line 182 of file addrman.h.
Referenced by Add_(), ClearNew(), Create(), Delete(), Find(), GetAddr_(), MakeTried(), Select_(), Serialize(), SwapRandom(), and Unserialize().
|
private |
last used nId
Definition at line 179 of file addrman.h.
Referenced by Clear(), Create(), and Unserialize().
|
protected |
secret key to randomize bucket select with
Definition at line 204 of file addrman.h.
Referenced by Add_(), Clear(), CAddrInfo::GetNewBucket(), Good_(), MakeTried(), Serialize(), Unserialize(), and ~CAddrMan().
|
private |
number of (unique) "new" entries
Definition at line 197 of file addrman.h.
Referenced by Add(), Add_(), Clear(), Delete(), MakeTried(), Select_(), Serialize(), and Unserialize().
|
private |
Definition at line 191 of file addrman.h.
Referenced by Add(), Clear(), MakeTried(), Select_(), Serialize(), and Unserialize().
|
private |
randomly-ordered vector of all nIds
Definition at line 188 of file addrman.h.
Referenced by Clear(), Create(), Delete(), GetAddr_(), size(), SwapRandom(), and Unserialize().
|
private |
list of "new" buckets
Definition at line 200 of file addrman.h.
Referenced by Add_(), Clear(), ClearNew(), Good_(), MakeTried(), Select_(), Serialize(), and Unserialize().
|
private |
list of "tried" buckets
Definition at line 194 of file addrman.h.
Referenced by Clear(), MakeTried(), Select_(), and Unserialize().