Skip to content

Commit

Permalink
Simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronek committed May 23, 2024
1 parent 063da61 commit d87bcca
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 29 deletions.
12 changes: 4 additions & 8 deletions src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,20 +1407,16 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
startGenesisLedger();
}
else if (
startUp == Config::LOAD || //
startUp == Config::LOAD_FILE || startUp == Config::REPLAY ||
startUp == Config::REPLAY_TRAP)
startUp == Config::LOAD || startUp == Config::LOAD_FILE ||
startUp == Config::REPLAY)
{
JLOG(m_journal.info()) << "Loading specified Ledger";

if (!loadOldLedger(
config_->START_LEDGER,
(startUp == Config::REPLAY ||
startUp == Config::REPLAY_TRAP),
startUp == Config::REPLAY,
startUp == Config::LOAD_FILE,
(startUp == Config::REPLAY_TRAP
? std::optional<uint256>(config_->TRAP_TX_HASH)
: std::nullopt)))
config_->TRAP_TX_HASH))
{
JLOG(m_journal.error())
<< "The specified ledger could not be loaded.";
Expand Down
7 changes: 2 additions & 5 deletions src/ripple/app/main/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,13 @@ run(int argc, char** argv)
config->START_LEDGER = vm["ledger"].as<std::string>();
if (vm.count("replay"))
{
config->START_UP = Config::REPLAY;
if (vm.count("trap_tx_hash"))
{
uint256 tmp = {};
auto hash = vm["trap_tx_hash"].as<std::string>();
if (tmp.parseHex(hash))
{
config->START_UP = Config::REPLAY_TRAP;
config->TRAP_TX_HASH = tmp;
}
else
Expand All @@ -700,8 +700,6 @@ run(int argc, char** argv)
return -1;
}
}
else
config->START_UP = Config::REPLAY;
}
else
config->START_UP = Config::LOAD;
Expand All @@ -726,8 +724,7 @@ run(int argc, char** argv)
if (vm.count("net") && !config->FAST_LOAD)
{
if ((config->START_UP == Config::LOAD) ||
(config->START_UP == Config::REPLAY) ||
(config->START_UP == Config::REPLAY_TRAP))
(config->START_UP == Config::REPLAY))
{
std::cerr << "Net and load/replay options are incompatible"
<< std::endl;
Expand Down
6 changes: 2 additions & 4 deletions src/ripple/app/rdb/backend/detail/impl/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ makeLedgerDBs(
boost::format("PRAGMA cache_size=-%d;") %
kilobytes(config.getValueFor(SizedItem::txnDBCache)));

if (!setup.standAlone || //
setup.startUp == Config::LOAD ||
if (!setup.standAlone || setup.startUp == Config::LOAD ||
setup.startUp == Config::LOAD_FILE ||
setup.startUp == Config::REPLAY ||
setup.startUp == Config::REPLAY_TRAP)
setup.startUp == Config::REPLAY)
{
// Check if AccountTransactions has primary key
std::string cid, name, type;
Expand Down
12 changes: 2 additions & 10 deletions src/ripple/core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,14 @@ class Config : public BasicConfig
// Entries from [ips_fixed] config stanza
std::vector<std::string> IPS_FIXED;

enum StartUpType {
FRESH,
NORMAL,
LOAD,
LOAD_FILE,
REPLAY,
NETWORK,
REPLAY_TRAP
};
enum StartUpType { FRESH, NORMAL, LOAD, LOAD_FILE, REPLAY, NETWORK };
StartUpType START_UP = NORMAL;

bool START_VALID = false;

std::string START_LEDGER;

uint256 TRAP_TX_HASH = {};
std::optional<uint256> TRAP_TX_HASH = {};

// Network parameters
uint32_t NETWORK_ID = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/ripple/core/DatabaseCon.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ class DatabaseCon
!setup.reporting && //
setup.startUp != Config::LOAD &&
setup.startUp != Config::LOAD_FILE &&
setup.startUp != Config::REPLAY &&
setup.startUp != Config::REPLAY_TRAP
setup.startUp != Config::REPLAY
? ""
: (setup.dataDir / dbName),
setup.commonPragma(),
Expand Down

0 comments on commit d87bcca

Please sign in to comment.