mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-01 00:15:51 +00:00
Decouple LedgerMaster from configuration
This commit is contained in:
committed by
Vinnie Falco
parent
430229fd84
commit
659cf0c221
@@ -76,11 +76,22 @@ public:
|
|||||||
std::atomic <std::uint32_t> mValidLedgerSeq;
|
std::atomic <std::uint32_t> mValidLedgerSeq;
|
||||||
std::atomic <std::uint32_t> mBuildingLedgerSeq;
|
std::atomic <std::uint32_t> mBuildingLedgerSeq;
|
||||||
|
|
||||||
|
// The server is in standalone mode
|
||||||
|
bool const standalone_;
|
||||||
|
|
||||||
|
// How many ledgers before the current ledger do we allow peers to request?
|
||||||
|
std::uint32_t const fetch_depth_;
|
||||||
|
|
||||||
|
// How much history do we want to keep
|
||||||
|
std::uint32_t const ledger_history_;
|
||||||
|
|
||||||
|
int const ledger_fetch_size_;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
LedgerMasterImp (Stoppable& parent,
|
LedgerMasterImp (bool standalone, std::uint32_t fetch_depth,
|
||||||
beast::insight::Collector::ptr const& collector,
|
std::uint32_t ledger_history, int ledger_fetch_size, Stoppable& parent,
|
||||||
beast::Journal journal)
|
beast::insight::Collector::ptr const& collector, beast::Journal journal)
|
||||||
: LedgerMaster (parent)
|
: LedgerMaster (parent)
|
||||||
, m_journal (journal)
|
, m_journal (journal)
|
||||||
, mLedgerHistory (collector)
|
, mLedgerHistory (collector)
|
||||||
@@ -99,6 +110,10 @@ public:
|
|||||||
, mValidLedgerClose (0)
|
, mValidLedgerClose (0)
|
||||||
, mValidLedgerSeq (0)
|
, mValidLedgerSeq (0)
|
||||||
, mBuildingLedgerSeq (0)
|
, mBuildingLedgerSeq (0)
|
||||||
|
, standalone_ (standalone)
|
||||||
|
, fetch_depth_ (fetch_depth)
|
||||||
|
, ledger_history_ (ledger_history)
|
||||||
|
, ledger_fetch_size_ (ledger_fetch_size)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +229,7 @@ public:
|
|||||||
mCurrentLedger.set (newLedger);
|
mCurrentLedger.set (newLedger);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getConfig().RUN_STANDALONE)
|
if (standalone_)
|
||||||
{
|
{
|
||||||
setFullLedger(newLedger, true, false);
|
setFullLedger(newLedger, true, false);
|
||||||
tryAdvance();
|
tryAdvance();
|
||||||
@@ -235,7 +250,7 @@ public:
|
|||||||
mCurrentLedger.set (newOL);
|
mCurrentLedger.set (newOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getConfig().RUN_STANDALONE)
|
if (standalone_)
|
||||||
{
|
{
|
||||||
setFullLedger(newLCL, true, false);
|
setFullLedger(newLCL, true, false);
|
||||||
tryAdvance();
|
tryAdvance();
|
||||||
@@ -458,8 +473,9 @@ public:
|
|||||||
// The earliest ledger we will let people fetch is ledger zero,
|
// The earliest ledger we will let people fetch is ledger zero,
|
||||||
// unless that creates a larger range than allowed
|
// unless that creates a larger range than allowed
|
||||||
std::uint32_t e = getClosedLedger()->getLedgerSeq();
|
std::uint32_t e = getClosedLedger()->getLedgerSeq();
|
||||||
if (e > getConfig().FETCH_DEPTH)
|
|
||||||
e -= getConfig().FETCH_DEPTH;
|
if (e > fetch_depth_)
|
||||||
|
e -= fetch_depth_;
|
||||||
else
|
else
|
||||||
e = 0;
|
e = 0;
|
||||||
return e;
|
return e;
|
||||||
@@ -704,7 +720,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
int getNeededValidations ()
|
int getNeededValidations ()
|
||||||
{
|
{
|
||||||
if (getConfig ().RUN_STANDALONE)
|
if (standalone_)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int minVal = mMinValidations;
|
int minVal = mMinValidations;
|
||||||
@@ -777,7 +793,7 @@ public:
|
|||||||
setBuildingLedger (0);
|
setBuildingLedger (0);
|
||||||
|
|
||||||
// No need to process validations in standalone mode
|
// No need to process validations in standalone mode
|
||||||
if (getConfig().RUN_STANDALONE)
|
if (standalone_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ledger->getLedgerSeq() <= mValidLedgerSeq)
|
if (ledger->getLedgerSeq() <= mValidLedgerSeq)
|
||||||
@@ -894,7 +910,7 @@ public:
|
|||||||
std::list<Ledger::pointer> pubLedgers = findNewLedgersToPublish ();
|
std::list<Ledger::pointer> pubLedgers = findNewLedgersToPublish ();
|
||||||
if (pubLedgers.empty())
|
if (pubLedgers.empty())
|
||||||
{
|
{
|
||||||
if (!getConfig().RUN_STANDALONE && !getApp().getFeeTrack().isLoadedLocal() &&
|
if (!standalone_ && !getApp().getFeeTrack().isLoadedLocal() &&
|
||||||
(getApp().getJobQueue().getJobCount(jtPUBOLDLEDGER) < 10) &&
|
(getApp().getJobQueue().getJobCount(jtPUBOLDLEDGER) < 10) &&
|
||||||
(mValidLedgerSeq == mPubLedgerSeq))
|
(mValidLedgerSeq == mPubLedgerSeq))
|
||||||
{ // We are in sync, so can acquire
|
{ // We are in sync, so can acquire
|
||||||
@@ -905,7 +921,7 @@ public:
|
|||||||
}
|
}
|
||||||
WriteLog (lsTRACE, LedgerMaster) << "tryAdvance discovered missing " << missing;
|
WriteLog (lsTRACE, LedgerMaster) << "tryAdvance discovered missing " << missing;
|
||||||
if ((missing != RangeSet::absent) && (missing > 0) &&
|
if ((missing != RangeSet::absent) && (missing > 0) &&
|
||||||
shouldAcquire(mValidLedgerSeq, getConfig().LEDGER_HISTORY, missing) &&
|
shouldAcquire(mValidLedgerSeq, ledger_history_, missing) &&
|
||||||
((mFillInProgress == 0) || (missing > mFillInProgress)))
|
((mFillInProgress == 0) || (missing > mFillInProgress)))
|
||||||
{
|
{
|
||||||
WriteLog (lsTRACE, LedgerMaster) << "advanceThread should acquire";
|
WriteLog (lsTRACE, LedgerMaster) << "advanceThread should acquire";
|
||||||
@@ -956,7 +972,7 @@ public:
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (int i = 0; i < getConfig().getSize(siLedgerFetch); ++i)
|
for (int i = 0; i < ledger_fetch_size_; ++i)
|
||||||
{
|
{
|
||||||
std::uint32_t seq = missing - i;
|
std::uint32_t seq = missing - i;
|
||||||
uint256 hash = nextLedger->getLedgerHash(seq);
|
uint256 hash = nextLedger->getLedgerHash(seq);
|
||||||
@@ -1195,7 +1211,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getConfig().RUN_STANDALONE)
|
if (!standalone_)
|
||||||
{ // don't pathfind with a ledger that's more than 60 seconds old
|
{ // don't pathfind with a ledger that's more than 60 seconds old
|
||||||
std::int64_t age = getApp().getOPs().getCloseTimeNC();
|
std::int64_t age = getApp().getOPs().getCloseTimeNC();
|
||||||
age -= static_cast<std::int64_t> (lastLedger->getCloseTimeNC());
|
age -= static_cast<std::int64_t> (lastLedger->getCloseTimeNC());
|
||||||
@@ -1479,12 +1495,12 @@ bool LedgerMaster::shouldAcquire (
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr <LedgerMaster>
|
std::unique_ptr <LedgerMaster>
|
||||||
make_LedgerMaster (beast::Stoppable& parent,
|
make_LedgerMaster (bool standalone, std::uint32_t fetch_depth,
|
||||||
beast::insight::Collector::ptr const& collector,
|
std::uint32_t ledger_history, int ledger_fetch_size, beast::Stoppable& parent,
|
||||||
beast::Journal journal)
|
beast::insight::Collector::ptr const& collector, beast::Journal journal)
|
||||||
{
|
{
|
||||||
return std::make_unique <LedgerMasterImp> (
|
return std::make_unique <LedgerMasterImp> (standalone, fetch_depth,
|
||||||
parent, collector, journal);
|
ledger_history, ledger_fetch_size, parent, collector, journal);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // ripple
|
} // ripple
|
||||||
|
|||||||
@@ -151,9 +151,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr <LedgerMaster>
|
std::unique_ptr <LedgerMaster>
|
||||||
make_LedgerMaster (beast::Stoppable& parent,
|
make_LedgerMaster (bool standalone, std::uint32_t fetch_depth,
|
||||||
beast::insight::Collector::ptr const& collector,
|
std::uint32_t ledger_history, int ledger_fetch_size, beast::Stoppable& parent,
|
||||||
beast::Journal journal);
|
beast::insight::Collector::ptr const& collector, beast::Journal journal);
|
||||||
|
|
||||||
} // ripple
|
} // ripple
|
||||||
|
|
||||||
|
|||||||
@@ -289,7 +289,9 @@ public:
|
|||||||
, m_pathRequests (new PathRequests (
|
, m_pathRequests (new PathRequests (
|
||||||
m_logs.journal("PathRequest"), m_collectorManager->collector ()))
|
m_logs.journal("PathRequest"), m_collectorManager->collector ()))
|
||||||
|
|
||||||
, m_ledgerMaster (make_LedgerMaster (*m_jobQueue,
|
, m_ledgerMaster (make_LedgerMaster (getConfig ().RUN_STANDALONE,
|
||||||
|
getConfig ().FETCH_DEPTH, getConfig ().LEDGER_HISTORY,
|
||||||
|
getConfig ().getSize (siLedgerFetch), *m_jobQueue,
|
||||||
m_collectorManager->collector (), m_logs.journal("LedgerMaster")))
|
m_collectorManager->collector (), m_logs.journal("LedgerMaster")))
|
||||||
|
|
||||||
// VFALCO NOTE must come before NetworkOPs to prevent a crash due
|
// VFALCO NOTE must come before NetworkOPs to prevent a crash due
|
||||||
|
|||||||
Reference in New Issue
Block a user