mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-19 20:20:00 +01:00
p2p, refactor: return std::optional<CNetAddr> in LookupHost
This commit is contained in:
@@ -713,9 +713,10 @@ static RPCHelpMan setban()
|
||||
isSubnet = true;
|
||||
|
||||
if (!isSubnet) {
|
||||
CNetAddr resolved;
|
||||
LookupHost(request.params[0].get_str(), resolved, false);
|
||||
netAddr = resolved;
|
||||
const std::optional<CNetAddr> addr{LookupHost(request.params[0].get_str(), false)};
|
||||
if (addr.has_value()) {
|
||||
netAddr = addr.value();
|
||||
}
|
||||
}
|
||||
else
|
||||
LookupSubNet(request.params[0].get_str(), subNet);
|
||||
@@ -943,11 +944,11 @@ static RPCHelpMan addpeeraddress()
|
||||
const bool tried{request.params[2].isNull() ? false : request.params[2].get_bool()};
|
||||
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
CNetAddr net_addr;
|
||||
std::optional<CNetAddr> net_addr{LookupHost(addr_string, false)};
|
||||
bool success{false};
|
||||
|
||||
if (LookupHost(addr_string, net_addr, false)) {
|
||||
CService service{net_addr, port};
|
||||
if (net_addr.has_value()) {
|
||||
CService service{net_addr.value(), port};
|
||||
CAddress address{MaybeFlipIPv6toCJDNS(service), ServiceFlags{NODE_NETWORK | NODE_WITNESS}};
|
||||
address.nTime = Now<NodeSeconds>();
|
||||
// The source address is set equal to the address. This is equivalent to the peer
|
||||
|
||||
Reference in New Issue
Block a user