mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Simplify LedgerMaster:
- Eliminate `tune` member function and allow `LedgerHistory` to fully initialize itself.
This commit is contained in:
committed by
manojsdoshi
parent
6faaa91850
commit
c7e6803956
@@ -26,14 +26,6 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// VFALCO TODO replace macros
|
||||
|
||||
#ifndef CACHED_LEDGER_NUM
|
||||
#define CACHED_LEDGER_NUM 96
|
||||
#endif
|
||||
|
||||
std::chrono::seconds constexpr CachedLedgerAge = std::chrono::minutes{2};
|
||||
|
||||
// FIXME: Need to clean up ledgers by index at some point
|
||||
|
||||
LedgerHistory::LedgerHistory(
|
||||
@@ -44,8 +36,8 @@ LedgerHistory::LedgerHistory(
|
||||
, mismatch_counter_(collector->make_counter("ledger.history", "mismatch"))
|
||||
, m_ledgers_by_hash(
|
||||
"LedgerCache",
|
||||
CACHED_LEDGER_NUM,
|
||||
CachedLedgerAge,
|
||||
app_.config().getValueFor(SizedItem::ledgerSize),
|
||||
std::chrono::seconds{app_.config().getValueFor(SizedItem::ledgerAge)},
|
||||
stopwatch(),
|
||||
app_.journal("TaggedCache"))
|
||||
, m_consensus_validated(
|
||||
@@ -523,13 +515,6 @@ LedgerHistory::fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
LedgerHistory::tune(int size, std::chrono::seconds age)
|
||||
{
|
||||
m_ledgers_by_hash.setTargetSize(size);
|
||||
m_ledgers_by_hash.setTargetAge(age);
|
||||
}
|
||||
|
||||
void
|
||||
LedgerHistory::clearLedgerCachePrior(LedgerIndex seq)
|
||||
{
|
||||
|
||||
@@ -70,13 +70,6 @@ public:
|
||||
LedgerHash
|
||||
getLedgerHash(LedgerIndex ledgerIndex);
|
||||
|
||||
/** Set the history cache's parameters
|
||||
@param size The target size of the cache
|
||||
@param age The target age of the cache, in seconds
|
||||
*/
|
||||
void
|
||||
tune(int size, std::chrono::seconds age);
|
||||
|
||||
/** Remove stale cache entries
|
||||
*/
|
||||
void
|
||||
|
||||
@@ -219,8 +219,6 @@ public:
|
||||
bool
|
||||
getFullValidatedRange(std::uint32_t& minVal, std::uint32_t& maxVal);
|
||||
|
||||
void
|
||||
tune(int size, std::chrono::seconds age);
|
||||
void
|
||||
sweep();
|
||||
float
|
||||
|
||||
@@ -1624,7 +1624,8 @@ LedgerMaster::newPFWork(
|
||||
const char* name,
|
||||
std::unique_lock<std::recursive_mutex>&)
|
||||
{
|
||||
if (mPathFindThread < 2 && app_.getPathRequests().requestsPending())
|
||||
if (!app_.isStopping() && mPathFindThread < 2 &&
|
||||
app_.getPathRequests().requestsPending())
|
||||
{
|
||||
JLOG(m_journal.debug())
|
||||
<< "newPFWork: Creating job. path find threads: "
|
||||
@@ -1868,12 +1869,6 @@ LedgerMaster::setLedgerRangePresent(std::uint32_t minV, std::uint32_t maxV)
|
||||
mCompleteLedgers.insert(range(minV, maxV));
|
||||
}
|
||||
|
||||
void
|
||||
LedgerMaster::tune(int size, std::chrono::seconds age)
|
||||
{
|
||||
mLedgerHistory.tune(size, age);
|
||||
}
|
||||
|
||||
void
|
||||
LedgerMaster::sweep()
|
||||
{
|
||||
@@ -2114,7 +2109,7 @@ LedgerMaster::doAdvance(std::unique_lock<std::recursive_mutex>& sl)
|
||||
{
|
||||
JLOG(m_journal.trace()) << "tryAdvance found " << pubLedgers.size()
|
||||
<< " ledgers to publish";
|
||||
for (auto ledger : pubLedgers)
|
||||
for (auto const& ledger : pubLedgers)
|
||||
{
|
||||
{
|
||||
ScopedUnlock sul{sl};
|
||||
|
||||
@@ -962,13 +962,6 @@ public:
|
||||
<< "' took " << elapsed.count() << " seconds.";
|
||||
}
|
||||
|
||||
// tune caches
|
||||
using namespace std::chrono;
|
||||
|
||||
m_ledgerMaster->tune(
|
||||
config_->getValueFor(SizedItem::ledgerSize),
|
||||
seconds{config_->getValueFor(SizedItem::ledgerAge)});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ sizedItems
|
||||
{SizedItem::sweepInterval, {{ 10, 30, 60, 90, 120 }}},
|
||||
{SizedItem::treeCacheSize, {{ 262144, 524288, 2097152, 4194304, 8388608 }}},
|
||||
{SizedItem::treeCacheAge, {{ 30, 60, 90, 120, 900 }}},
|
||||
{SizedItem::ledgerSize, {{ 32, 128, 256, 384, 768 }}},
|
||||
{SizedItem::ledgerAge, {{ 30, 90, 180, 240, 900 }}},
|
||||
{SizedItem::ledgerSize, {{ 32, 32, 64, 256, 384 }}},
|
||||
{SizedItem::ledgerAge, {{ 30, 60, 180, 300, 600 }}},
|
||||
{SizedItem::ledgerFetch, {{ 2, 3, 4, 5, 8 }}},
|
||||
{SizedItem::hashNodeDBCache, {{ 4, 12, 24, 64, 128 }}},
|
||||
{SizedItem::txnDBCache, {{ 4, 12, 24, 64, 128 }}},
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace ripple {
|
||||
Json::Value
|
||||
doLedgerAccept(RPC::JsonContext& context)
|
||||
{
|
||||
std::unique_lock lock{context.app.getMasterMutex()};
|
||||
Json::Value jvResult;
|
||||
|
||||
if (!context.app.config().standalone() || context.app.config().reporting())
|
||||
@@ -43,8 +42,8 @@ doLedgerAccept(RPC::JsonContext& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unique_lock lock{context.app.getMasterMutex()};
|
||||
context.netOps.acceptLedger();
|
||||
|
||||
jvResult[jss::ledger_current_index] =
|
||||
context.ledgerMaster.getCurrentLedgerIndex();
|
||||
}
|
||||
|
||||
@@ -318,9 +318,11 @@ public:
|
||||
{
|
||||
using namespace test::jtx;
|
||||
using namespace std::chrono_literals;
|
||||
Env env{*this};
|
||||
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->NODE_SIZE = 0;
|
||||
return cfg;
|
||||
})};
|
||||
Account const gw{"gateway"};
|
||||
env.app().getLedgerMaster().tune(0, 1h);
|
||||
auto const USD = gw["USD"];
|
||||
env.fund(XRP(100000), gw);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user