aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.h
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2021-10-01 17:26:08 +0100
committerJohn Newbery <john@johnnewbery.com>2021-10-28 14:00:21 +0100
commit2095df7b7bfcb9ab0c5710a93112f7f341e753c9 (patch)
tree22703ab84a8823e7ad923d8d6532ebb885d74aa7 /src/addrman.h
parent2658eb6d68460272deefb3fcc653b03f6ec6e7cf (diff)
downloadbitcoin-2095df7b7bfcb9ab0c5710a93112f7f341e753c9.tar.xz
[addrman] Add Add_() inner function, fix Add() return semantics
Previously, Add() would return true if the function created a new AddressInfo object, even if that object could not be successfully entered into the new table and was deleted. That would happen if the new table position was already taken and the existing entry could not be removed. Instead, return true if the new AddressInfo object is successfully entered into the new table. This fixes a bug in the "Added %i addresses" log, which would not always accurately log how many addresses had been added. p2p_addrv2_relay.py and p2p_addr_relay.py need to be updated since they were incorrectly asserting on the buggy log (assuming that addresses are added to addrman, when there could in fact be new table position collisions that prevent some of those address records from being added).
Diffstat (limited to 'src/addrman.h')
-rw-r--r--src/addrman.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/addrman.h b/src/addrman.h
index 1fbc827183..a9f697f66f 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -76,7 +76,8 @@ public:
* @param[in] source The address of the node that sent us these addr records.
* @param[in] nTimePenalty A "time penalty" to apply to the address record's nTime. If a peer
* sends us an address record with nTime=n, then we'll add it to our
- * addrman with nTime=(n - nTimePenalty). */
+ * addrman with nTime=(n - nTimePenalty).
+ * @return true if at least one address is successfully added. */
bool Add(const std::vector<CAddress>& vAddr, const CNetAddr& source, int64_t nTimePenalty = 0);
//! Mark an entry as accessible, possibly moving it from "new" to "tried".