mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Merge bitcoin/bitcoin#22576: doc: Update high-level addrman description
036d7eadf5
doc: Correct description of CAddrMan::Create() (Amiti Uttarwar)318176aff1
doc: Update high-level addrman description (Martin Zumsande) Pull request description: The high-level description of `addrman` has outdated information with respect to the eviction behavior, both for the New and Tried tables (at least since #5941) - this has confused me in the past. This PR corrects this and also adds basic info about the bucket size and position. ACKs for top commit: amitiuttarwar: reACK036d7eadf5
jnewbery: ACK036d7eadf5
Tree-SHA512: 3f0635d765f5e580a1fae31187742a833cef66ef2286d40eeb28f2253521260038e16e5f1a65741464a2ddfdbeb5c0f1bc38bf73841e600639033d59c3c534e4
This commit is contained in:
commit
3308c61091
1 changed files with 12 additions and 9 deletions
|
@ -104,19 +104,23 @@ public:
|
|||
* * Make sure no (localized) attacker can fill the entire table with his nodes/addresses.
|
||||
*
|
||||
* To that end:
|
||||
* * Addresses are organized into buckets.
|
||||
* * Addresses that have not yet been tried go into 1024 "new" buckets.
|
||||
* * Based on the address range (/16 for IPv4) of the source of information, 64 buckets are selected at random.
|
||||
* * Addresses are organized into buckets that can each store up to 64 entries.
|
||||
* * Addresses to which our node has not successfully connected go into 1024 "new" buckets.
|
||||
* * Based on the address range (/16 for IPv4) of the source of information, or if an asmap is provided,
|
||||
* the AS it belongs to (for IPv4/IPv6), 64 buckets are selected at random.
|
||||
* * The actual bucket is chosen from one of these, based on the range in which the address itself is located.
|
||||
* * The position in the bucket is chosen based on the full address.
|
||||
* * One single address can occur in up to 8 different buckets to increase selection chances for addresses that
|
||||
* are seen frequently. The chance for increasing this multiplicity decreases exponentially.
|
||||
* * When adding a new address to a full bucket, a randomly chosen entry (with a bias favoring less recently seen
|
||||
* ones) is removed from it first.
|
||||
* * When adding a new address to an occupied position of a bucket, it will not replace the existing entry
|
||||
* unless that address is also stored in another bucket or it doesn't meet one of several quality criteria
|
||||
* (see IsTerrible for exact criteria).
|
||||
* * Addresses of nodes that are known to be accessible go into 256 "tried" buckets.
|
||||
* * Each address range selects at random 8 of these buckets.
|
||||
* * The actual bucket is chosen from one of these, based on the full address.
|
||||
* * When adding a new good address to a full bucket, a randomly chosen entry (with a bias favoring less recently
|
||||
* tried ones) is evicted from it, back to the "new" buckets.
|
||||
* * When adding a new good address to an occupied position of a bucket, a FEELER connection to the
|
||||
* old address is attempted. The old entry is only replaced and moved back to the "new" buckets if this
|
||||
* attempt was unsuccessful.
|
||||
* * Bucket selection is based on cryptographic hashing, using a randomly-generated 256-bit key, which should not
|
||||
* be observable by adversaries.
|
||||
* * Several indexes are kept for high performance. Defining DEBUG_ADDRMAN will introduce frequent (and expensive)
|
||||
|
@ -696,8 +700,7 @@ private:
|
|||
//! Find an entry.
|
||||
CAddrInfo* Find(const CNetAddr& addr, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
//! find an entry, creating it if necessary.
|
||||
//! nTime and nServices of the found node are updated, if necessary.
|
||||
//! Create a new entry and add it to the internal data structures mapInfo, mapAddr and vRandom.
|
||||
CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
//! Swap two elements in vRandom.
|
||||
|
|
Loading…
Add table
Reference in a new issue