Pull multi-node timestamp estimation into a class
There is enough code there and enough interactions to justify an
interface. Put it behind an interface to make it much more clear and
easier to enforce what updates when and with what guarentees.
This should provide no functional change.
Change-Id: Idd2c1849c2641df828c26860c61e238f47d87f9e
diff --git a/aos/configuration.cc b/aos/configuration.cc
index ad2e295..b8a38bc 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -878,6 +878,16 @@
return nullptr;
}
+const Node *GetNode(const Configuration *config, size_t node_index) {
+ if (!MultiNode(config)) {
+ CHECK_EQ(node_index, 0u) << ": Invalid node in a single node world.";
+ return nullptr;
+ } else {
+ CHECK_LT(node_index, config->nodes()->size());
+ return config->nodes()->Get(node_index);
+ }
+}
+
const Node *GetNodeOrDie(const Configuration *config, const Node *node) {
if (!MultiNode(config)) {
CHECK(node == nullptr) << ": Provided a node in a single node world.";