aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/server_util.cpp
diff options
context:
space:
mode:
authorstratospher <44024636+stratospher@users.noreply.github.com>2023-10-03 19:37:56 +0530
committerstratospher <44024636+stratospher@users.noreply.github.com>2023-10-04 08:53:51 +0530
commite6e444c06cbf09380f9924dff3d21c1be15d1753 (patch)
tree996404bb43c2c5481a437431404afde07be9b215 /src/rpc/server_util.cpp
parentbf589a50a0d6a7b94f1ba1ddf24a1497fd35ad44 (diff)
downloadbitcoin-e6e444c06cbf09380f9924dff3d21c1be15d1753.tar.xz
refactor: add and use EnsureAnyAddrman in rpc
Diffstat (limited to 'src/rpc/server_util.cpp')
-rw-r--r--src/rpc/server_util.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/rpc/server_util.cpp b/src/rpc/server_util.cpp
index 1d4afb3758..efd4a43c28 100644
--- a/src/rpc/server_util.cpp
+++ b/src/rpc/server_util.cpp
@@ -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));
+}