Add SourceNodeIndex to compute the source node per channel

We keep doing this type of thing.  Time to go write a function.  Doing a
bunch of string compares is slow, so we should really cache it up front.

It feels like it might be getting close to time to try to write a class
which will let us compute and cache all these things reasonably
efficiently and move logger and others over to it.  Let's start with a
function to compute the things we care about.

Change-Id: I4b788b1395656e8e6e6c3c7eb28f4d410080c636
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/configuration_test.cc b/aos/configuration_test.cc
index ff991a2..c650a5d 100644
--- a/aos/configuration_test.cc
+++ b/aos/configuration_test.cc
@@ -857,6 +857,15 @@
   EXPECT_EQ(nullptr, GetNodeFromHostname(&config.message(), "3"));
 }
 
+// Tests that SourceNodeIndex reasonably handles a multi-node log file.
+TEST_F(ConfigurationTest, SourceNodeIndex) {
+  FlatbufferDetachedBuffer<Configuration> config =
+      ReadConfig(ArtifactPath("aos/testdata/good_multinode.json"));
+  std::vector<size_t> result = SourceNodeIndex(&config.message());
+
+  EXPECT_THAT(result, ::testing::ElementsAreArray({0, 1, 0, 0}));
+}
+
 }  // namespace testing
 }  // namespace configuration
 }  // namespace aos