diff options
author | Amiti Uttarwar <amiti@uttarwar.org> | 2023-02-18 18:29:45 -0700 |
---|---|---|
committer | Amiti Uttarwar <amiti@uttarwar.org> | 2023-03-17 17:59:02 -0700 |
commit | 6b229284fd2209938ee8fdffed4d080395b3aa05 (patch) | |
tree | 930526ea48150eeda675ace5e77bdecaa6c9ac46 /src/addrman.h | |
parent | 26c3bf11e2487ed0ac578fb92619c148336003cb (diff) | |
download | bitcoin-6b229284fd2209938ee8fdffed4d080395b3aa05.tar.xz |
addrman: add functionality to select by network
Add an optional parameter to the addrman Select function that allows callers to
specify which network the returned address should be on. Ensure that the proper
table is selected with different cases of whether the new or tried table has
network addresses that match.
Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
Diffstat (limited to 'src/addrman.h')
-rw-r--r-- | src/addrman.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/addrman.h b/src/addrman.h index 374996e501..c8e31fe283 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -146,11 +146,12 @@ public: /** * Choose an address to connect to. * - * @param[in] new_only Whether to only select addresses from the new table. + * @param[in] new_only Whether to only select addresses from the new table. + * @param[in] network Select only addresses of this network (nullopt = all) * @return CAddress The record for the selected peer. * seconds The last time we attempted to connect to that peer. */ - std::pair<CAddress, NodeSeconds> Select(bool new_only = false) const; + std::pair<CAddress, NodeSeconds> Select(bool new_only = false, std::optional<Network> network = std::nullopt) const; /** * Return all or many randomly selected addresses, optionally by network. |