mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
Merge bitcoin/bitcoin#26261: p2p: cleanup LookupIntern, Lookup and LookupHost
5c832c3820p2p, refactor: return `std::optional<CNetAddr>` in `LookupHost` (brunoerg)34bcdfc6a6p2p, refactor: return vector/optional<CService> in `Lookup` (brunoerg)7799eb125bp2p, refactor: return `std::vector<CNetAddr>` in `LookupHost` (brunoerg)5c1774a563p2p, refactor: return `std::vector<CNetAddr>` in `LookupIntern` (brunoerg) Pull request description: Continuation of #26078. To improve readability instead of returning a bool and passing stuff by reference, this PR changes: - `LookupHost` to return `std::vector<CNetAddr>` - `LookupHost` to return `std::optional<CNetAddr>` - `Lookup` to return `std::vector<CService>` - `Lookup` to return `std::optional<CService>`. - `LookupIntern` to return `std::vector<CNetAddr>` As discussed in #26078, it would be better to avoid using `optional` in some cases, but for specific `Lookup` and `LookupHost` functions it's necessary to use `optional` to verify if they were able to catch some data from their overloaded function. ACKs for top commit: achow101: ACK5c832c3820stickies-v: re-ACK5c832c3820- just addressing two nits, no other changes theStack: re-ACK5c832c3820Tree-SHA512: ea346fdc54463999646269bd600cd4a1590ef958001d2f0fc2be608ca51e1b4365efccca76dd4972b023e12fcc6e67d226608b0df7beb901bdeadd19948df840
This commit is contained in:
@@ -88,18 +88,18 @@ bool NetWhitebindPermissions::TryParse(const std::string& str, NetWhitebindPermi
|
||||
if (!TryParsePermissionFlags(str, flags, offset, error)) return false;
|
||||
|
||||
const std::string strBind = str.substr(offset);
|
||||
CService addrBind;
|
||||
if (!Lookup(strBind, addrBind, 0, false)) {
|
||||
const std::optional<CService> addrBind{Lookup(strBind, 0, false)};
|
||||
if (!addrBind.has_value()) {
|
||||
error = ResolveErrMsg("whitebind", strBind);
|
||||
return false;
|
||||
}
|
||||
if (addrBind.GetPort() == 0) {
|
||||
if (addrBind.value().GetPort() == 0) {
|
||||
error = strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind);
|
||||
return false;
|
||||
}
|
||||
|
||||
output.m_flags = flags;
|
||||
output.m_service = addrBind;
|
||||
output.m_service = addrBind.value();
|
||||
error = Untranslated("");
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user