From 2ca7ef7f5f5fdabfe14fdb7b2f26f43015c57e80 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Tue, 23 Mar 2021 16:00:46 -0300 Subject: [PATCH] Rename isRouter -> isSNode The isRouter wording was quite confusing, especially in a call such as: router->Configure(config, opts.isRouter, nodedb) --- daemon/lokinet.cpp | 8 ++++---- include/llarp.hpp | 2 +- llarp/config/key_manager.cpp | 4 ++-- llarp/config/key_manager.hpp | 4 ++-- llarp/context.cpp | 2 +- llarp/router/abstractrouter.hpp | 2 +- llarp/router/router.cpp | 4 ++-- llarp/router/router.hpp | 2 +- llarp/tooling/router_hive.cpp | 6 +++--- test/exit/test_llarp_exit_context.cpp | 2 +- test/regress/2020-06-08-key-backup-bug.cpp | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/daemon/lokinet.cpp b/daemon/lokinet.cpp index a9ddb4263..316d1b856 100644 --- a/daemon/lokinet.cpp +++ b/daemon/lokinet.cpp @@ -268,7 +268,7 @@ run_main_context(std::optional confFile, const llarp::RuntimeOptions o { conf = std::make_shared(llarp::GetDefaultDataDir()); } - if (!conf->Load(confFile, opts.isRouter)) + if (!conf->Load(confFile, opts.isSNode)) throw std::runtime_error{"Config file parsing failed"}; ctx = std::make_shared(); @@ -486,7 +486,7 @@ lokinet_main(int argc, char* argv[]) if (result.count("router") > 0) { - opts.isRouter = true; + opts.isSNode = true; } if (result.count("force") > 0) @@ -518,7 +518,7 @@ lokinet_main(int argc, char* argv[]) { try { - llarp::ensureConfig(basedir, *configFile, overwrite, opts.isRouter); + llarp::ensureConfig(basedir, *configFile, overwrite, opts.isSNode); } catch (std::exception& ex) { @@ -548,7 +548,7 @@ lokinet_main(int argc, char* argv[]) try { llarp::ensureConfig( - llarp::GetDefaultDataDir(), llarp::GetDefaultConfigPath(), overwrite, opts.isRouter); + llarp::GetDefaultDataDir(), llarp::GetDefaultConfigPath(), overwrite, opts.isSNode); } catch (std::exception& ex) { diff --git a/include/llarp.hpp b/include/llarp.hpp index 7d326600e..33fe6bfc1 100644 --- a/include/llarp.hpp +++ b/include/llarp.hpp @@ -33,7 +33,7 @@ namespace llarp { bool background = false; bool debug = false; - bool isRouter = false; + bool isSNode = false; }; struct Context diff --git a/llarp/config/key_manager.cpp b/llarp/config/key_manager.cpp index 1637c95a7..14e9298cb 100644 --- a/llarp/config/key_manager.cpp +++ b/llarp/config/key_manager.cpp @@ -12,7 +12,7 @@ namespace llarp {} bool - KeyManager::initialize(const llarp::Config& config, bool genIfAbsent, bool isRouter) + KeyManager::initialize(const llarp::Config& config, bool genIfAbsent, bool isSNode) { if (m_initialized) return false; @@ -51,7 +51,7 @@ namespace llarp // we need to back up keys if our self.signed doesn't appear to have a // valid signature - m_needBackup = (isRouter and not rc.VerifySignature()); + m_needBackup = (isSNode and not rc.VerifySignature()); // if our RC file can't be verified, assume it is out of date (e.g. uses // older encryption) and needs to be regenerated. before doing so, backup diff --git a/llarp/config/key_manager.hpp b/llarp/config/key_manager.hpp index 74e741b70..bb0c2075a 100644 --- a/llarp/config/key_manager.hpp +++ b/llarp/config/key_manager.hpp @@ -40,10 +40,10 @@ namespace llarp /// @param config should be a prepared config object /// @param genIfAbsent determines whether or not we will create files if they /// do not exist. - /// @param isRouter + /// @param isSNode /// @return true on success, false otherwise bool - initialize(const llarp::Config& config, bool genIfAbsent, bool isRouter); + initialize(const llarp::Config& config, bool genIfAbsent, bool isSNode); /// Obtain the self-signed RouterContact /// diff --git a/llarp/context.cpp b/llarp/context.cpp index 47c8a68f6..5ec161b4e 100644 --- a/llarp/context.cpp +++ b/llarp/context.cpp @@ -77,7 +77,7 @@ namespace llarp nodedb = std::make_shared( nodedb_dir, [r = router.get()](auto call) { r->QueueDiskIO(std::move(call)); }); - if (!router->Configure(config, opts.isRouter, nodedb)) + if (!router->Configure(config, opts.isSNode, nodedb)) throw std::runtime_error("Failed to configure router"); } diff --git a/llarp/router/abstractrouter.hpp b/llarp/router/abstractrouter.hpp index bb7a4d2d5..f4f7a1b8c 100644 --- a/llarp/router/abstractrouter.hpp +++ b/llarp/router/abstractrouter.hpp @@ -172,7 +172,7 @@ namespace llarp Sign(Signature& sig, const llarp_buffer_t& buf) const = 0; virtual bool - Configure(std::shared_ptr conf, bool isRouter, std::shared_ptr nodedb) = 0; + Configure(std::shared_ptr conf, bool isSNode, std::shared_ptr nodedb) = 0; virtual bool IsServiceNode() const = 0; diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 769565bdb..812cfa955 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -284,7 +284,7 @@ namespace llarp } bool - Router::Configure(std::shared_ptr c, bool isRouter, std::shared_ptr nodedb) + Router::Configure(std::shared_ptr c, bool isSNode, std::shared_ptr nodedb) { m_Config = std::move(c); auto& conf = *m_Config; @@ -314,7 +314,7 @@ namespace llarp } // fetch keys - if (not m_keyManager->initialize(conf, true, isRouter)) + if (not m_keyManager->initialize(conf, true, isSNode)) throw std::runtime_error("KeyManager failed to initialize"); if (!FromConfig(conf)) throw std::runtime_error("FromConfig() failed"); diff --git a/llarp/router/router.hpp b/llarp/router/router.hpp index 86b1efd6c..3300eb597 100644 --- a/llarp/router/router.hpp +++ b/llarp/router/router.hpp @@ -344,7 +344,7 @@ namespace llarp Close(); bool - Configure(std::shared_ptr conf, bool isRouter, std::shared_ptr nodedb) override; + Configure(std::shared_ptr conf, bool isSNode, std::shared_ptr nodedb) override; bool StartRpcServer() override; diff --git a/llarp/tooling/router_hive.cpp b/llarp/tooling/router_hive.cpp index 01e22f59f..d06bd8c97 100644 --- a/llarp/tooling/router_hive.cpp +++ b/llarp/tooling/router_hive.cpp @@ -13,12 +13,12 @@ using namespace std::chrono_literals; namespace tooling { void - RouterHive::AddRouter(const std::shared_ptr& config, bool isRouter) + RouterHive::AddRouter(const std::shared_ptr& config, bool isSNode) { - auto& container = (isRouter ? relays : clients); + auto& container = (isSNode ? relays : clients); llarp::RuntimeOptions opts; - opts.isRouter = isRouter; + opts.isSNode = isSNode; Context_ptr context = std::make_shared(this); context->Configure(config); diff --git a/test/exit/test_llarp_exit_context.cpp b/test/exit/test_llarp_exit_context.cpp index cc100587d..a90646572 100644 --- a/test/exit/test_llarp_exit_context.cpp +++ b/test/exit/test_llarp_exit_context.cpp @@ -5,7 +5,7 @@ #include #include -static const llarp::RuntimeOptions opts = {.background = false, .debug = false, .isRouter = true}; +static const llarp::RuntimeOptions opts = {.background = false, .debug = false, .isSNode = true}; std::shared_ptr make_context() diff --git a/test/regress/2020-06-08-key-backup-bug.cpp b/test/regress/2020-06-08-key-backup-bug.cpp index 2a659baaf..0de1fc85b 100644 --- a/test/regress/2020-06-08-key-backup-bug.cpp +++ b/test/regress/2020-06-08-key-backup-bug.cpp @@ -11,7 +11,7 @@ static std::shared_ptr make_context(std::optional keyfile) { auto conf = std::make_shared(fs::current_path()); - conf->Load(std::nullopt, opts.isRouter); + conf->Load(std::nullopt, opts.isSNode); conf->network.m_endpointType = "null"; conf->network.m_keyfile = keyfile; conf->bootstrap.seednode = true;