mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
rpc: simplify/constify getnodeaddresses code
This commit is contained in:
parent
3bb6e7b655
commit
1b9189866a
1 changed files with 4 additions and 8 deletions
|
@ -863,15 +863,11 @@ static RPCHelpMan getnodeaddresses()
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 1;
|
const int count{request.params[0].isNull() ? 1 : request.params[0].get_int()};
|
||||||
if (!request.params[0].isNull()) {
|
if (count < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Address count out of range");
|
||||||
count = request.params[0].get_int();
|
|
||||||
if (count < 0) {
|
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Address count out of range");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// returns a shuffled list of CAddress
|
// returns a shuffled list of CAddress
|
||||||
std::vector<CAddress> vAddr = node.connman->GetAddresses(count, /* max_pct */ 0);
|
const std::vector<CAddress> vAddr{node.connman->GetAddresses(count, /* max_pct */ 0)};
|
||||||
UniValue ret(UniValue::VARR);
|
UniValue ret(UniValue::VARR);
|
||||||
|
|
||||||
for (const CAddress& addr : vAddr) {
|
for (const CAddress& addr : vAddr) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue