@@ -931,26 +931,22 @@ static RPCHelpMan addpeeraddress()
931
931
throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Address manager functionality missing or disabled" );
932
932
}
933
933
934
- UniValue obj (UniValue::VOBJ);
935
-
936
- std::string addr_string = request.params [0 ].get_str ();
937
- uint16_t port{static_cast <uint16_t >(request.params [1 ].get_int ())};
934
+ const std::string& addr_string{request.params [0 ].get_str ()};
935
+ const uint16_t port{static_cast <uint16_t >(request.params [1 ].get_int ())};
938
936
937
+ UniValue obj (UniValue::VOBJ);
939
938
CNetAddr net_addr;
940
- if (!LookupHost (addr_string, net_addr, false )) {
941
- obj.pushKV (" success" , false );
942
- return obj;
943
- }
944
- CAddress address = CAddress ({net_addr, port}, ServiceFlags (NODE_NETWORK|NODE_WITNESS));
945
- address.nTime = GetAdjustedTime ();
946
- // The source address is set equal to the address. This is equivalent to the peer
947
- // announcing itself.
948
- if (!node.addrman ->Add (address, address)) {
949
- obj.pushKV (" success" , false );
950
- return obj;
939
+ bool success{false };
940
+
941
+ if (LookupHost (addr_string, net_addr, false )) {
942
+ CAddress address{CAddress ({net_addr, port}, ServiceFlags (NODE_NETWORK | NODE_WITNESS))};
943
+ address.nTime = GetAdjustedTime ();
944
+ // The source address is set equal to the address. This is equivalent to the peer
945
+ // announcing itself.
946
+ if (node.addrman ->Add (address, address)) success = true ;
951
947
}
952
948
953
- obj.pushKV (" success" , true );
949
+ obj.pushKV (" success" , success );
954
950
return obj;
955
951
},
956
952
};
0 commit comments