Pass RuntimeOptions instead of 'bool isRelay'

pull/1314/head
Stephen Shelton 4 years ago
parent 984015587d
commit 0aa43c6b07
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C

@ -99,7 +99,7 @@ run_main_context(const fs::path confFile, const llarp::RuntimeOptions opts)
conf.Load(confFile, opts.isRouter, confFile.parent_path());
ctx = std::shared_ptr<llarp::Context>();
ctx->Configure(opts.isRouter, {});
ctx->Configure(opts, {});
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);
@ -107,7 +107,7 @@ run_main_context(const fs::path confFile, const llarp::RuntimeOptions opts)
signal(SIGHUP, handle_signal);
#endif
ctx->Setup(opts.isRouter);
ctx->Setup(opts);
llarp::util::SetThreadName("llarp-mainloop");

@ -60,7 +60,7 @@ namespace llarp
LoadDatabase();
void
Setup(bool isRelay);
Setup(const RuntimeOptions& opts);
int
Run(const RuntimeOptions& opts);
@ -69,7 +69,7 @@ namespace llarp
HandleSignal(int sig);
bool
Configure(bool isRelay, std::optional<fs::path> dataDir);
Configure(const RuntimeOptions& opts, std::optional<fs::path> dataDir);
bool
IsUp() const;

@ -28,7 +28,7 @@ namespace llarp
}
bool
Context::Configure(bool isRelay, std::optional<fs::path> dataDir)
Context::Configure(const RuntimeOptions& opts, std::optional<fs::path> dataDir)
{
if (config)
throw std::runtime_error("Re-configure not supported");
@ -39,7 +39,7 @@ namespace llarp
if (configfile.size())
{
if (!config->Load(configfile.c_str(), isRelay, defaultDataDir))
if (!config->Load(configfile.c_str(), opts.isRouter, defaultDataDir))
{
config.release();
llarp::LogError("failed to load config file ", configfile);
@ -78,7 +78,7 @@ namespace llarp
}
void
Context::Setup(bool isRelay)
Context::Setup(const RuntimeOptions& opts)
{
llarp::LogInfo(llarp::VERSION_FULL, " ", llarp::RELEASE_MOTTO);
llarp::LogInfo("starting up");
@ -98,7 +98,7 @@ namespace llarp
nodedb = std::make_unique<llarp_nodedb>(router->diskworker(), nodedb_dir);
if (!router->Configure(config.get(), isRelay, nodedb.get()))
if (!router->Configure(config.get(), opts.isRouter, nodedb.get()))
throw std::runtime_error("Failed to configure router");
// must be done after router is made so we can use its disk io worker

@ -5,12 +5,14 @@
#include <service/context.hpp>
#include <catch2/catch.hpp>
llarp::RuntimeOptions opts = {false, false, false};
/// make a llarp_main* with 1 endpoint that specifies a keyfile
static std::shared_ptr<llarp::Context>
make_context(std::optional<fs::path> keyfile)
{
auto context = std::make_shared<llarp::Context>();
context->Configure(false, {});
context->Configure(opts, {});
context->config->network.m_endpointType = "null";
context->config->network.m_keyfile = keyfile;
@ -35,7 +37,7 @@ TEST_CASE("key backup bug regression test", "[regress]")
for (size_t index = 0; index < 10; index++)
{
auto ctx = make_context(path);
REQUIRE_NOTHROW(ctx->Setup(false));
REQUIRE_NOTHROW(ctx->Setup(opts));
ctx->CallSafe([ctx, index, &endpointAddress, &path]() {
auto ep = ctx->router->hiddenServiceContext().GetDefault();
REQUIRE(ep != nullptr);

Loading…
Cancel
Save