Inject Config:

* Use dependency injections instead
* Remove deprecated fee interfaces
This commit is contained in:
Nik Bougalis
2015-09-18 12:15:12 -07:00
committed by Vinnie Falco
parent c7b3153958
commit fa796a2eb5
57 changed files with 541 additions and 688 deletions

View File

@@ -119,7 +119,7 @@ void
FeeVoteImpl::doValidation (Ledger::ref lastClosedLedger,
STObject& baseValidation)
{
if (lastClosedLedger->getBaseFee () != target_.reference_fee)
if (lastClosedLedger->fees().base != target_.reference_fee)
{
if (journal_.info) journal_.info <<
"Voting for base fee of " << target_.reference_fee;
@@ -127,7 +127,7 @@ FeeVoteImpl::doValidation (Ledger::ref lastClosedLedger,
baseValidation.setFieldU64 (sfBaseFee, target_.reference_fee);
}
if (lastClosedLedger->getReserve (0) != target_.account_reserve)
if (lastClosedLedger->fees().accountReserve(0) != target_.account_reserve)
{
if (journal_.info) journal_.info <<
"Voting for base resrve of " << target_.account_reserve;
@@ -135,7 +135,7 @@ FeeVoteImpl::doValidation (Ledger::ref lastClosedLedger,
baseValidation.setFieldU32(sfReserveBase, target_.account_reserve);
}
if (lastClosedLedger->getReserveInc () != target_.owner_reserve)
if (lastClosedLedger->fees().increment != target_.owner_reserve)
{
if (journal_.info) journal_.info <<
"Voting for reserve increment of " << target_.owner_reserve;
@@ -154,13 +154,13 @@ FeeVoteImpl::doVoting (Ledger::ref lastClosedLedger,
assert ((lastClosedLedger->info().seq % 256) == 0);
detail::VotableInteger<std::uint64_t> baseFeeVote (
lastClosedLedger->getBaseFee (), target_.reference_fee);
lastClosedLedger->fees().base, target_.reference_fee);
detail::VotableInteger<std::uint32_t> baseReserveVote (
lastClosedLedger->getReserve (0), target_.account_reserve);
lastClosedLedger->fees().accountReserve(0).drops(), target_.account_reserve);
detail::VotableInteger<std::uint32_t> incReserveVote (
lastClosedLedger->getReserveInc (), target_.owner_reserve);
lastClosedLedger->fees().increment, target_.owner_reserve);
for (auto const& e : set)
{
@@ -203,9 +203,9 @@ FeeVoteImpl::doVoting (Ledger::ref lastClosedLedger,
std::uint32_t const incReserve = incReserveVote.getVotes ();
// add transactions to our position
if ((baseFee != lastClosedLedger->getBaseFee ()) ||
(baseReserve != lastClosedLedger->getReserve (0)) ||
(incReserve != lastClosedLedger->getReserveInc ()))
if ((baseFee != lastClosedLedger->fees().base) ||
(baseReserve != lastClosedLedger->fees().accountReserve(0)) ||
(incReserve != lastClosedLedger->fees().increment))
{
if (journal_.warning) journal_.warning <<
"We are voting for a fee change: " << baseFee <<

View File

@@ -129,7 +129,7 @@ public:
, m_amendmentBlocked (false)
, m_heartbeatTimer (this)
, m_clusterTimer (this)
, mConsensus (make_Consensus ())
, mConsensus (make_Consensus (app_.config()))
, m_ledgerMaster (ledgerMaster)
, mLastLoadBase (256)
, mLastLoadFactor (256)
@@ -678,7 +678,7 @@ void NetworkOPsImp::submitTransaction (STTx::pointer iTrans)
// Tell the call to checkSign() whether multisign is enabled.
if (!passesLocalChecks (*trans, reason) ||
!trans->checkSign (m_ledgerMaster.getValidatedRules().enabled(
featureMultiSign, getConfig().features)))
featureMultiSign, app_.config().features)))
{
m_journal.warning << "Submitted transaction " <<
(reason.empty () ? "has bad signature" : "error: " + reason);
@@ -845,7 +845,7 @@ void NetworkOPsImp::apply (std::unique_lock<std::mutex>& batchLock)
auto const result = ripple::apply(app_,
view, *e.transaction->getSTransaction(), flags,
app_.getHashRouter().sigVerify(),
getConfig(), j);
app_.config(), j);
e.result = result.first;
e.applied = result.second;
return result.second;
@@ -1321,7 +1321,7 @@ bool NetworkOPsImp::beginConsensus (uint256 const& networkClosed)
// Create a consensus object to get consensus on this ledger
assert (!mLedgerConsensus);
prevLedger->setImmutable ();
prevLedger->setImmutable (app_.config());
mLedgerConsensus = mConsensus->startRound (
app_,
@@ -1838,10 +1838,10 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
if (admin)
{
if (getConfig ().VALIDATION_PUB.isValid ())
if (app_.config().VALIDATION_PUB.isValid ())
{
info[jss::pubkey_validator] =
getConfig ().VALIDATION_PUB.humanNodePublic ();
app_.config().VALIDATION_PUB.humanNodePublic ();
}
else
{
@@ -1926,8 +1926,8 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
if (lpClosed)
{
std::uint64_t baseFee = lpClosed->getBaseFee ();
std::uint64_t baseRef = lpClosed->getReferenceFeeUnits ();
std::uint64_t baseFee = lpClosed->fees().base;
std::uint64_t baseRef = lpClosed->fees().units;
Json::Value l (Json::objectValue);
l[jss::seq] = Json::UInt (lpClosed->info().seq);
l[jss::hash] = to_string (lpClosed->getHash ());
@@ -1935,9 +1935,9 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
if (!human)
{
l[jss::base_fee] = Json::Value::UInt (baseFee);
l[jss::reserve_base] = Json::Value::UInt (lpClosed->getReserve (0));
l[jss::reserve_base] = Json::Value::UInt (lpClosed->fees().accountReserve(0).drops());
l[jss::reserve_inc] =
Json::Value::UInt (lpClosed->getReserveInc ());
Json::Value::UInt (lpClosed->fees().increment);
l[jss::close_time] =
Json::Value::UInt (lpClosed->info().closeTime);
}
@@ -1947,11 +1947,11 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
SYSTEM_CURRENCY_PARTS;
l[jss::reserve_base_xrp] =
static_cast<double> (Json::UInt (
lpClosed->getReserve (0) * baseFee / baseRef))
lpClosed->fees().accountReserve(0).drops() * baseFee / baseRef))
/ SYSTEM_CURRENCY_PARTS;
l[jss::reserve_inc_xrp] =
static_cast<double> (Json::UInt (
lpClosed->getReserveInc () * baseFee / baseRef))
lpClosed->fees().increment * baseFee / baseRef))
/ SYSTEM_CURRENCY_PARTS;
auto const nowOffset = app_.timeKeeper().nowOffset();
@@ -2060,10 +2060,10 @@ void NetworkOPsImp::pubLedger (Ledger::ref lpAccepted)
= Json::Value::UInt (lpAccepted->info().closeTime);
jvObj[jss::fee_ref]
= Json::UInt (lpAccepted->getReferenceFeeUnits ());
jvObj[jss::fee_base] = Json::UInt (lpAccepted->getBaseFee ());
jvObj[jss::reserve_base] = Json::UInt (lpAccepted->getReserve (0));
jvObj[jss::reserve_inc] = Json::UInt (lpAccepted->getReserveInc ());
= Json::UInt (lpAccepted->fees().units);
jvObj[jss::fee_base] = Json::UInt (lpAccepted->fees().base);
jvObj[jss::reserve_base] = Json::UInt (lpAccepted->fees().accountReserve(0).drops());
jvObj[jss::reserve_inc] = Json::UInt (lpAccepted->fees().increment);
jvObj[jss::txn_count] = Json::UInt (alpAccepted->getTxnCount ());
@@ -2417,10 +2417,10 @@ bool NetworkOPsImp::subLedger (InfoSub::ref isrListener, Json::Value& jvResult)
jvResult[jss::ledger_time]
= Json::Value::UInt (lpClosed->info().closeTime);
jvResult[jss::fee_ref]
= Json::UInt (lpClosed->getReferenceFeeUnits ());
jvResult[jss::fee_base] = Json::UInt (lpClosed->getBaseFee ());
jvResult[jss::reserve_base] = Json::UInt (lpClosed->getReserve (0));
jvResult[jss::reserve_inc] = Json::UInt (lpClosed->getReserveInc ());
= Json::UInt (lpClosed->fees().units);
jvResult[jss::fee_base] = Json::UInt (lpClosed->fees().base);
jvResult[jss::reserve_base] = Json::UInt (lpClosed->fees().accountReserve(0).drops());
jvResult[jss::reserve_inc] = Json::UInt (lpClosed->fees().increment);
}
if ((mMode >= omSYNCING) && !isNeedNetworkLedger ())

View File

@@ -671,19 +671,28 @@ setup_SHAMapStore (Config const& c)
{
SHAMapStore::Setup setup;
auto const& sec = c.section (ConfigSection::nodeDatabase ());
get_if_exists (sec, "online_delete", setup.deleteInterval);
// Get existing settings and add some default values if not specified:
setup.nodeDatabase = c.section (ConfigSection::nodeDatabase ());
// These two parameters apply only to RocksDB. We want to give them sensible
// defaults if no values are specified.
if (!setup.nodeDatabase.exists ("cache_mb"))
setup.nodeDatabase.set ("cache_mb", std::to_string (c.getSize (siHashNodeDBCache)));
if (!setup.nodeDatabase.exists ("filter_bits") && (c.NODE_SIZE >= 2))
setup.nodeDatabase.set ("filter_bits", "10");
get_if_exists (setup.nodeDatabase, "online_delete", setup.deleteInterval);
if (setup.deleteInterval)
get_if_exists (sec, "advisory_delete", setup.advisoryDelete);
get_if_exists (setup.nodeDatabase, "advisory_delete", setup.advisoryDelete);
setup.ledgerHistory = c.LEDGER_HISTORY;
setup.nodeDatabase = c[ConfigSection::nodeDatabase ()];
setup.databasePath = c.legacy("database_path");
get_if_exists (sec, "delete_batch", setup.deleteBatch);
get_if_exists (sec, "backOff", setup.backOff);
get_if_exists (sec, "age_threshold", setup.ageThreshold);
get_if_exists (setup.nodeDatabase, "delete_batch", setup.deleteBatch);
get_if_exists (setup.nodeDatabase, "backOff", setup.backOff);
get_if_exists (setup.nodeDatabase, "age_threshold", setup.ageThreshold);
return setup;
}

View File

@@ -365,7 +365,7 @@ private:
// --> strValidatorsSrc: source details for display
// --> naNodePublic: remote source public key - not valid for local
// --> vsWhy: reason for adding validator to SeedDomains or SeedNodes.
int processValidators (std::string const& strSite, std::string const& strValidatorsSrc, RippleAddress const& naNodePublic, ValidatorSource vsWhy, IniFileSections::mapped_type* pmtVecStrValidators);
int processValidators (std::string const& strSite, std::string const& strValidatorsSrc, RippleAddress const& naNodePublic, ValidatorSource vsWhy, IniFileSections::mapped_type const* pmtVecStrValidators);
// Process a ripple.txt.
void processFile (std::string const& strDomain, RippleAddress const& naNodePublic, IniFileSections secSite);
@@ -780,38 +780,40 @@ void UniqueNodeListImp::nodeBootstrap()
bool bLoaded = iDomains || iNodes;
// Always merge in the file specified in the config.
if (!getConfig ().VALIDATORS_FILE.empty ())
if (!app_.config().VALIDATORS_FILE.empty ())
{
WriteLog (lsINFO, UniqueNodeList) << "Bootstrapping UNL: loading from unl_default.";
bLoaded = nodeLoad (getConfig ().VALIDATORS_FILE);
bLoaded = nodeLoad (app_.config().VALIDATORS_FILE);
}
// If never loaded anything try the current directory.
if (!bLoaded && getConfig ().VALIDATORS_FILE.empty ())
if (!bLoaded && app_.config().VALIDATORS_FILE.empty ())
{
WriteLog (lsINFO, UniqueNodeList) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.")
% getConfig ().VALIDATORS_BASE);
% app_.config().VALIDATORS_BASE);
bLoaded = nodeLoad (getConfig ().VALIDATORS_BASE);
bLoaded = nodeLoad (app_.config().VALIDATORS_BASE);
}
// Always load from rippled.cfg
if (!getConfig ().validators.empty ())
if (!app_.config().validators.empty ())
{
RippleAddress naInvalid; // Don't want a referrer on added entries.
WriteLog (lsINFO, UniqueNodeList) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.")
% getConfig ().CONFIG_FILE);
% app_.config().CONFIG_FILE);
if (processValidators ("local", getConfig ().CONFIG_FILE.string (), naInvalid, vsConfig, &getConfig ().validators))
if (processValidators ("local",
app_.config().CONFIG_FILE.string (), naInvalid,
vsConfig, &(app_.config().validators)))
bLoaded = true;
}
if (!bLoaded)
{
WriteLog (lsINFO, UniqueNodeList) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.")
% getConfig ().VALIDATORS_SITE);
% app_.config().VALIDATORS_SITE);
nodeNetwork ();
}
@@ -879,14 +881,14 @@ bool UniqueNodeListImp::nodeLoad (boost::filesystem::path pConfig)
void UniqueNodeListImp::nodeNetwork()
{
if (!getConfig ().VALIDATORS_SITE.empty ())
if (!app_.config().VALIDATORS_SITE.empty ())
{
HTTPClient::get (
true,
app_.getIOService (),
getConfig ().VALIDATORS_SITE,
app_.config().VALIDATORS_SITE,
443,
getConfig ().VALIDATORS_URI,
app_.config().VALIDATORS_URI,
VALIDATORS_FILE_BYTES_MAX,
boost::posix_time::seconds (VALIDATORS_FETCH_SECONDS),
std::bind (&UniqueNodeListImp::validatorsResponse, this,
@@ -1017,7 +1019,7 @@ bool UniqueNodeListImp::miscSave()
void UniqueNodeListImp::trustedLoad()
{
boost::regex rNode ("\\`\\s*(\\S+)[\\s]*(.*)\\'");
for (auto const& c : getConfig ().CLUSTER_NODES)
for (auto const& c : app_.config().CLUSTER_NODES)
{
boost::smatch match;
@@ -1981,7 +1983,7 @@ void UniqueNodeListImp::processIps (std::string const& strSite, RippleAddress co
// --> strValidatorsSrc: source details for display
// --> naNodePublic: remote source public key - not valid for local
// --> vsWhy: reason for adding validator to SeedDomains or SeedNodes.
int UniqueNodeListImp::processValidators (std::string const& strSite, std::string const& strValidatorsSrc, RippleAddress const& naNodePublic, ValidatorSource vsWhy, IniFileSections::mapped_type* pmtVecStrValidators)
int UniqueNodeListImp::processValidators (std::string const& strSite, std::string const& strValidatorsSrc, RippleAddress const& naNodePublic, ValidatorSource vsWhy, IniFileSections::mapped_type const* pmtVecStrValidators)
{
std::string strNodePublic = naNodePublic.isValid () ? naNodePublic.humanNodePublic () : strValidatorsSrc;
int iValues = 0;
@@ -2364,7 +2366,7 @@ bool UniqueNodeListImp::validatorsResponse (const boost::system::error_code& err
if (!err)
{
nodeProcess ("network", strResponse, getConfig ().VALIDATORS_SITE);
nodeProcess ("network", strResponse, app_.config().VALIDATORS_SITE);
}
else
{
@@ -2398,7 +2400,7 @@ void UniqueNodeListImp::nodeProcess (std::string const& strSite, std::string con
else
{
WriteLog (lsWARNING, UniqueNodeList) << boost::str (boost::format ("'%s' missing [" SECTION_VALIDATORS "].")
% getConfig ().VALIDATORS_BASE);
% app_.config().VALIDATORS_BASE);
}
}