Example #1
0
static void
setForceSCPFlag(Config const& cfg, bool isOn)
{
    VirtualClock clock;
    Application::pointer app = Application::create(clock, cfg, false);

    if (checkInitialized(app))
    {
        app->getPersistentState().setState(
            PersistentState::kForceSCPOnNextLaunch, (isOn ? "true" : "false"));
        if (isOn)
        {
            LOG(INFO) << "* ";
            LOG(INFO) << "* The `force scp` flag has been set in the db.";
            LOG(INFO) << "* ";
            LOG(INFO)
                << "* The next launch will start scp from the account balances";
            LOG(INFO) << "* as they stand in the db now, without waiting to "
                         "hear from";
            LOG(INFO) << "* the network.";
            LOG(INFO) << "* ";
        }
        else
        {
            LOG(INFO) << "* ";
            LOG(INFO) << "* The `force scp` flag has been cleared.";
            LOG(INFO) << "* The next launch will start normally.";
            LOG(INFO) << "* ";
        }
    }
}
Example #2
0
bool
checkInitialized(Application::pointer app)
{
    if (app->getPersistentState().getState(
            PersistentState::kDatabaseInitialized) != "true")
    {
        LOG(INFO) << "* ";
        LOG(INFO) << "* The database has not yet been initialized. Try --newdb";
        LOG(INFO) << "* ";
        return false;
    }
    return true;
}
Example #3
0
static bool
checkInitialized(Application::pointer app)
{
    try
    {
        // check to see if the state table exists
        app->getPersistentState().getState(PersistentState::kDatabaseSchema);
    }
    catch (...)
    {
        LOG(INFO) << "* ";
        LOG(INFO) << "* The database has not yet been initialized. Try --newdb";
        LOG(INFO) << "* ";
        return false;
    }
    return true;
}
Example #4
0
void
setForceSCPFlag(Config& cfg)
{
    VirtualClock clock;
    Application::pointer app = Application::create(clock, cfg);

    if (checkInitialized(app))
    {
        app->getPersistentState().setState(
            PersistentState::kForceSCPOnNextLaunch, "true");
        LOG(INFO) << "* ";
        LOG(INFO) << "* The `force scp` flag has been set in the db. The next "
                     "launch will";
        LOG(INFO) << "* and start scp from the account balances as they stand";
        LOG(INFO)
            << "* in the db now, without waiting to hear from the network.";
        LOG(INFO) << "* ";
    }
}
Example #5
0
void
initializeDatabase(Config& cfg)
{
    cfg.REBUILD_DB = false; // don't wipe the db until we read whether it was
                            // already initialized
    VirtualClock clock;
    Application::pointer app = Application::create(clock, cfg);

    auto wipeMsg = (app->getPersistentState().getState(
                        PersistentState::kDatabaseInitialized) == "true"
                        ? " wiped and initialized"
                        : " initialized");

    app->getDatabase().initialize();

    LOG(INFO) << "* ";
    LOG(INFO) << "* The database has been" << wipeMsg
              << ". The next launch will catchup from the";
    LOG(INFO) << "* network afresh.";
    LOG(INFO) << "* ";
}