communication: refactor SyncLogicHandler to not need a ConfParameter reference

refs #4208

Change-Id: I5194c0a775dc1581af3a6ebd2db3699892671fb4
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index cd9e17a..8193a60 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2022,  The University of Memphis,
+ * Copyright (c) 2014-2024,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -24,8 +24,6 @@
 #include "logger.hpp"
 #include "utility/name-helper.hpp"
 
-#include <boost/lexical_cast.hpp>
-
 namespace nlsr {
 
 INIT_LOGGER(SyncLogicHandler);
@@ -33,24 +31,22 @@
 const std::string LSA_COMPONENT{"LSA"};
 
 SyncLogicHandler::SyncLogicHandler(ndn::Face& face, ndn::KeyChain& keyChain,
-                                   IsLsaNew isLsaNew, const ConfParameter& conf)
+                                   IsLsaNew isLsaNew, const SyncLogicOptions& opts)
   : m_isLsaNew(std::move(isLsaNew))
-  , m_confParam(conf)
-  , m_nameLsaUserPrefix(ndn::Name(m_confParam.getSyncUserPrefix()).append(boost::lexical_cast<std::string>(Lsa::Type::NAME)))
-  , m_syncLogic(face, keyChain, m_confParam.getSyncProtocol(), m_confParam.getSyncPrefix(),
-                m_nameLsaUserPrefix, m_confParam.getSyncInterestLifetime(),
+  , m_routerPrefix(opts.routerPrefix)
+  , m_hyperbolicState(opts.hyperbolicState)
+  , m_nameLsaUserPrefix(makeLsaUserPrefix(opts.userPrefix, Lsa::Type::NAME))
+  , m_adjLsaUserPrefix(makeLsaUserPrefix(opts.userPrefix, Lsa::Type::ADJACENCY))
+  , m_coorLsaUserPrefix(makeLsaUserPrefix(opts.userPrefix, Lsa::Type::COORDINATE))
+  , m_syncLogic(face, keyChain, opts.syncProtocol, opts.syncPrefix,
+                m_nameLsaUserPrefix, opts.syncInterestLifetime,
                 std::bind(&SyncLogicHandler::processUpdate, this, _1, _2, _3))
 {
-  m_adjLsaUserPrefix = ndn::Name(m_confParam.getSyncUserPrefix())
-                         .append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
-  m_coorLsaUserPrefix = ndn::Name(m_confParam.getSyncUserPrefix())
-                         .append(boost::lexical_cast<std::string>(Lsa::Type::COORDINATE));
-
-  if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_ON) {
+  if (m_hyperbolicState != HYPERBOLIC_STATE_ON) {
     m_syncLogic.addUserNode(m_adjLsaUserPrefix);
   }
 
-  if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
+  if (m_hyperbolicState != HYPERBOLIC_STATE_OFF) {
     m_syncLogic.addUserNode(m_coorLsaUserPrefix);
   }
 }
@@ -83,37 +79,36 @@
 {
   NLSR_LOG_DEBUG("Origin Router of update: " << originRouter);
 
-  // A router should not try to fetch its own LSA
-  if (originRouter != m_confParam.getRouterPrefix()) {
+  if (originRouter == m_routerPrefix) {
+    // A router should not try to fetch its own LSA
+    return;
+  }
 
-    Lsa::Type lsaType;
-    std::istringstream(updateName.get(updateName.size()-1).toUri()) >> lsaType;
+  auto lsaType = boost::lexical_cast<Lsa::Type>(updateName.get(-1).toUri());
+  NLSR_LOG_DEBUG("Received sync update with higher " << lsaType <<
+                  " sequence number than entry in LSDB");
 
-    NLSR_LOG_DEBUG("Received sync update with higher " << lsaType <<
-                   " sequence number than entry in LSDB");
-
-    if (m_isLsaNew(originRouter, lsaType, seqNo, incomingFaceId)) {
-      if (lsaType == Lsa::Type::ADJACENCY && seqNo != 0 &&
-          m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
-        NLSR_LOG_ERROR("Got an update for adjacency LSA when hyperbolic routing " <<
-                       "is enabled. Not going to fetch.");
-        return;
-      }
-
-      if (lsaType == Lsa::Type::COORDINATE && seqNo != 0 &&
-          m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
-        NLSR_LOG_ERROR("Got an update for coordinate LSA when link-state " <<
-                       "is enabled. Not going to fetch.");
-        return;
-      }
-
-      onNewLsa(updateName, seqNo, originRouter, incomingFaceId);
+  if (m_isLsaNew(originRouter, lsaType, seqNo, incomingFaceId)) {
+    if (lsaType == Lsa::Type::ADJACENCY && seqNo != 0 &&
+        m_hyperbolicState == HYPERBOLIC_STATE_ON) {
+      NLSR_LOG_ERROR("Got an update for adjacency LSA when hyperbolic routing "
+                      "is enabled. Not going to fetch.");
+      return;
     }
+
+    if (lsaType == Lsa::Type::COORDINATE && seqNo != 0 &&
+        m_hyperbolicState == HYPERBOLIC_STATE_OFF) {
+      NLSR_LOG_ERROR("Got an update for coordinate LSA when link-state "
+                      "is enabled. Not going to fetch.");
+      return;
+    }
+
+    onNewLsa(updateName, seqNo, originRouter, incomingFaceId);
   }
 }
 
 void
-SyncLogicHandler::publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo)
+SyncLogicHandler::publishRoutingUpdate(Lsa::Type type, uint64_t seqNo)
 {
   switch (type) {
   case Lsa::Type::ADJACENCY: