topology: Introduce get_node()

This commit is contained in:
Tomasz Grabiec
2023-07-03 23:55:55 +02:00
parent f2fdf37415
commit 0e3eac29d0

View File

@@ -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<std::runtime_error>(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;