Rename isRouter -> isSNode

The isRouter wording was quite confusing, especially in a call such as:

    router->Configure(config, opts.isRouter, nodedb)
pull/1576/head
Jason Rhinelander 3 years ago committed by Jeff Becker
parent 1d6ad7284c
commit 2ca7ef7f5f
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -268,7 +268,7 @@ run_main_context(std::optional<fs::path> confFile, const llarp::RuntimeOptions o
{ {
conf = std::make_shared<llarp::Config>(llarp::GetDefaultDataDir()); conf = std::make_shared<llarp::Config>(llarp::GetDefaultDataDir());
} }
if (!conf->Load(confFile, opts.isRouter)) if (!conf->Load(confFile, opts.isSNode))
throw std::runtime_error{"Config file parsing failed"}; throw std::runtime_error{"Config file parsing failed"};
ctx = std::make_shared<llarp::Context>(); ctx = std::make_shared<llarp::Context>();
@ -486,7 +486,7 @@ lokinet_main(int argc, char* argv[])
if (result.count("router") > 0) if (result.count("router") > 0)
{ {
opts.isRouter = true; opts.isSNode = true;
} }
if (result.count("force") > 0) if (result.count("force") > 0)
@ -518,7 +518,7 @@ lokinet_main(int argc, char* argv[])
{ {
try try
{ {
llarp::ensureConfig(basedir, *configFile, overwrite, opts.isRouter); llarp::ensureConfig(basedir, *configFile, overwrite, opts.isSNode);
} }
catch (std::exception& ex) catch (std::exception& ex)
{ {
@ -548,7 +548,7 @@ lokinet_main(int argc, char* argv[])
try try
{ {
llarp::ensureConfig( llarp::ensureConfig(
llarp::GetDefaultDataDir(), llarp::GetDefaultConfigPath(), overwrite, opts.isRouter); llarp::GetDefaultDataDir(), llarp::GetDefaultConfigPath(), overwrite, opts.isSNode);
} }
catch (std::exception& ex) catch (std::exception& ex)
{ {

@ -33,7 +33,7 @@ namespace llarp
{ {
bool background = false; bool background = false;
bool debug = false; bool debug = false;
bool isRouter = false; bool isSNode = false;
}; };
struct Context struct Context

@ -12,7 +12,7 @@ namespace llarp
{} {}
bool bool
KeyManager::initialize(const llarp::Config& config, bool genIfAbsent, bool isRouter) KeyManager::initialize(const llarp::Config& config, bool genIfAbsent, bool isSNode)
{ {
if (m_initialized) if (m_initialized)
return false; return false;
@ -51,7 +51,7 @@ namespace llarp
// we need to back up keys if our self.signed doesn't appear to have a // we need to back up keys if our self.signed doesn't appear to have a
// valid signature // 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 // 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 // older encryption) and needs to be regenerated. before doing so, backup

@ -40,10 +40,10 @@ namespace llarp
/// @param config should be a prepared config object /// @param config should be a prepared config object
/// @param genIfAbsent determines whether or not we will create files if they /// @param genIfAbsent determines whether or not we will create files if they
/// do not exist. /// do not exist.
/// @param isRouter /// @param isSNode
/// @return true on success, false otherwise /// @return true on success, false otherwise
bool bool
initialize(const llarp::Config& config, bool genIfAbsent, bool isRouter); initialize(const llarp::Config& config, bool genIfAbsent, bool isSNode);
/// Obtain the self-signed RouterContact /// Obtain the self-signed RouterContact
/// ///

@ -77,7 +77,7 @@ namespace llarp
nodedb = std::make_shared<NodeDB>( nodedb = std::make_shared<NodeDB>(
nodedb_dir, [r = router.get()](auto call) { r->QueueDiskIO(std::move(call)); }); 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"); throw std::runtime_error("Failed to configure router");
} }

@ -172,7 +172,7 @@ namespace llarp
Sign(Signature& sig, const llarp_buffer_t& buf) const = 0; Sign(Signature& sig, const llarp_buffer_t& buf) const = 0;
virtual bool virtual bool
Configure(std::shared_ptr<Config> conf, bool isRouter, std::shared_ptr<NodeDB> nodedb) = 0; Configure(std::shared_ptr<Config> conf, bool isSNode, std::shared_ptr<NodeDB> nodedb) = 0;
virtual bool virtual bool
IsServiceNode() const = 0; IsServiceNode() const = 0;

@ -284,7 +284,7 @@ namespace llarp
} }
bool bool
Router::Configure(std::shared_ptr<Config> c, bool isRouter, std::shared_ptr<NodeDB> nodedb) Router::Configure(std::shared_ptr<Config> c, bool isSNode, std::shared_ptr<NodeDB> nodedb)
{ {
m_Config = std::move(c); m_Config = std::move(c);
auto& conf = *m_Config; auto& conf = *m_Config;
@ -314,7 +314,7 @@ namespace llarp
} }
// fetch keys // 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"); throw std::runtime_error("KeyManager failed to initialize");
if (!FromConfig(conf)) if (!FromConfig(conf))
throw std::runtime_error("FromConfig() failed"); throw std::runtime_error("FromConfig() failed");

@ -344,7 +344,7 @@ namespace llarp
Close(); Close();
bool bool
Configure(std::shared_ptr<Config> conf, bool isRouter, std::shared_ptr<NodeDB> nodedb) override; Configure(std::shared_ptr<Config> conf, bool isSNode, std::shared_ptr<NodeDB> nodedb) override;
bool bool
StartRpcServer() override; StartRpcServer() override;

@ -13,12 +13,12 @@ using namespace std::chrono_literals;
namespace tooling namespace tooling
{ {
void void
RouterHive::AddRouter(const std::shared_ptr<llarp::Config>& config, bool isRouter) RouterHive::AddRouter(const std::shared_ptr<llarp::Config>& config, bool isSNode)
{ {
auto& container = (isRouter ? relays : clients); auto& container = (isSNode ? relays : clients);
llarp::RuntimeOptions opts; llarp::RuntimeOptions opts;
opts.isRouter = isRouter; opts.isSNode = isSNode;
Context_ptr context = std::make_shared<HiveContext>(this); Context_ptr context = std::make_shared<HiveContext>(this);
context->Configure(config); context->Configure(config);

@ -5,7 +5,7 @@
#include <llarp.hpp> #include <llarp.hpp>
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
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<llarp::Context> std::shared_ptr<llarp::Context>
make_context() make_context()

@ -11,7 +11,7 @@ static std::shared_ptr<llarp::Context>
make_context(std::optional<fs::path> keyfile) make_context(std::optional<fs::path> keyfile)
{ {
auto conf = std::make_shared<llarp::Config>(fs::current_path()); auto conf = std::make_shared<llarp::Config>(fs::current_path());
conf->Load(std::nullopt, opts.isRouter); conf->Load(std::nullopt, opts.isSNode);
conf->network.m_endpointType = "null"; conf->network.m_endpointType = "null";
conf->network.m_keyfile = keyfile; conf->network.m_keyfile = keyfile;
conf->bootstrap.seednode = true; conf->bootstrap.seednode = true;

Loading…
Cancel
Save