From 0e3eac29d0b29d5bbb484b8f34b4874d88861d2d Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Mon, 3 Jul 2023 23:55:55 +0200 Subject: [PATCH] topology: Introduce get_node() --- locator/topology.hh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/locator/topology.hh b/locator/topology.hh index 077dc6cff4..536cd7f9dc 100644 --- a/locator/topology.hh +++ b/locator/topology.hh @@ -171,6 +171,14 @@ public: // Returns a pointer to the node if found, or nullptr otherwise. const node* find_node(host_id id) const noexcept; + const node& get_node(host_id id) const { + auto n = find_node(id); + if (!n) { + throw_with_backtrace(format("Node {} not found in topology", id)); + } + return *n; + }; + // Looks up a node by its inet_address. // Returns a pointer to the node if found, or nullptr otherwise. const node* find_node(const inet_address& ep) const noexcept;