refactor: add and use EnsureAnyAddrman in rpc

This commit is contained in:
stratospher
2023-10-03 19:37:56 +05:30
parent bf589a50a0
commit e6e444c06c
3 changed files with 29 additions and 22 deletions

View File

@@ -108,3 +108,16 @@ PeerManager& EnsurePeerman(const NodeContext& node)
}
return *node.peerman;
}
AddrMan& EnsureAddrman(const NodeContext& node)
{
if (!node.addrman) {
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Address manager functionality missing or disabled");
}
return *node.addrman;
}
AddrMan& EnsureAnyAddrman(const std::any& context)
{
return EnsureAddrman(EnsureAnyNodeContext(context));
}