![]() |
Bitcoin ABC
0.26.3
P2P Digital Currency
|
Stochastic address manager. More...
#include <addrman.h>
Public Member Functions | |
AddrMan (std::vector< bool > asmap, int32_t consistency_check_ratio) | |
~AddrMan () | |
template<typename Stream > | |
void | Serialize (Stream &s_) const |
template<typename Stream > | |
void | Unserialize (Stream &s_) |
size_t | size () const |
Return the number of (unique) addresses in all tables. More... | |
bool | Add (const std::vector< CAddress > &vAddr, const CNetAddr &source, int64_t nTimePenalty=0) |
Add addresses to addrman's new table. More... | |
void | Good (const CService &addr, bool test_before_evict=true, int64_t nTime=GetAdjustedTime()) |
Mark an entry as accessible, possibly moving it from "new" to "tried". More... | |
void | Attempt (const CService &addr, bool fCountFailure, int64_t nTime=GetAdjustedTime()) |
Mark an entry as connection attempted to. More... | |
void | ResolveCollisions () |
See if any to-be-evicted tried table entries have been tested and if so resolve the collisions. More... | |
std::pair< CAddress, int64_t > | SelectTriedCollision () |
Randomly select an address in the tried table that another address is attempting to evict. More... | |
std::pair< CAddress, int64_t > | Select (bool newOnly=false) const |
Choose an address to connect to. More... | |
std::vector< CAddress > | GetAddr (size_t max_addresses, size_t max_pct, std::optional< Network > network) const |
Return all or many randomly selected addresses, optionally by network. More... | |
void | Connected (const CService &addr, int64_t nTime=GetAdjustedTime()) |
We have successfully connected to this peer. More... | |
void | SetServices (const CService &addr, ServiceFlags nServices) |
Update an entry's service bits. More... | |
const std::vector< bool > & | GetAsmap () const |
void | Clear () |
void | MakeDeterministic () |
Ensure that bucket placement is always the same for testing purposes. More... | |
Private Attributes | |
const std::unique_ptr< AddrManImpl > | m_impl |
Friends | |
class | AddrManTest |
class | AddrManCorrupted |
Stochastic address manager.
Design goals:
To that end:
AddrMan::AddrMan | ( | std::vector< bool > | asmap, |
int32_t | consistency_check_ratio | ||
) |
|
default |
bool AddrMan::Add | ( | const std::vector< CAddress > & | vAddr, |
const CNetAddr & | source, | ||
int64_t | nTimePenalty = 0 |
||
) |
Add addresses to addrman's new table.
Definition at line 1319 of file addrman.cpp.
void AddrMan::Attempt | ( | const CService & | addr, |
bool | fCountFailure, | ||
int64_t | nTime = GetAdjustedTime() |
||
) |
Mark an entry as connection attempted to.
Definition at line 1329 of file addrman.cpp.
void AddrMan::Clear | ( | ) |
void AddrMan::Connected | ( | const CService & | addr, |
int64_t | nTime = GetAdjustedTime() |
||
) |
We have successfully connected to this peer.
Calling this function updates the CAddress's nTime, which is used in our IsTerrible() decisions and gossiped to peers. Callers should be careful that updating this information doesn't leak topology information to network spies.
net_processing calls this function when it disconnects from a peer to not leak information about currently connected peers.
[in] | addr | The address of the peer we were connected to |
[in] | nTime | The time that we were last connected to this peer |
Definition at line 1350 of file addrman.cpp.
std::vector< CAddress > AddrMan::GetAddr | ( | size_t | max_addresses, |
size_t | max_pct, | ||
std::optional< Network > | network | ||
) | const |
Return all or many randomly selected addresses, optionally by network.
[in] | max_addresses | Maximum number of addresses to return (0 = all). |
[in] | max_pct | Maximum percentage of addresses to return (0 = all). |
[in] | network | Select only addresses of this network (nullopt = all). |
Definition at line 1345 of file addrman.cpp.
const std::vector< bool > & AddrMan::GetAsmap | ( | ) | const |
void AddrMan::Good | ( | const CService & | addr, |
bool | test_before_evict = true , |
||
int64_t | nTime = GetAdjustedTime() |
||
) |
Mark an entry as accessible, possibly moving it from "new" to "tried".
Definition at line 1324 of file addrman.cpp.
void AddrMan::MakeDeterministic | ( | ) |
Ensure that bucket placement is always the same for testing purposes.
Definition at line 1366 of file addrman.cpp.
void AddrMan::ResolveCollisions | ( | ) |
See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
Definition at line 1333 of file addrman.cpp.
std::pair< CAddress, int64_t > AddrMan::Select | ( | bool | newOnly = false | ) | const |
Choose an address to connect to.
[in] | newOnly | Whether to only select addresses from the new table. |
Definition at line 1341 of file addrman.cpp.
std::pair< CAddress, int64_t > AddrMan::SelectTriedCollision | ( | ) |
Randomly select an address in the tried table that another address is attempting to evict.
Definition at line 1337 of file addrman.cpp.
template void AddrMan::Serialize | ( | Stream & | s_ | ) | const |
Definition at line 1298 of file addrman.cpp.
void AddrMan::SetServices | ( | const CService & | addr, |
ServiceFlags | nServices | ||
) |
Update an entry's service bits.
Definition at line 1354 of file addrman.cpp.
size_t AddrMan::size | ( | ) | const |
Return the number of (unique) addresses in all tables.
Definition at line 1315 of file addrman.cpp.
template void AddrMan::Unserialize | ( | Stream & | s_ | ) |
Definition at line 1302 of file addrman.cpp.
|
private |