mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 23:15:52 +00:00
Add config "ledger_history_index" functionality (RIPD-559)
This commit is contained in:
committed by
Vinnie Falco
parent
94629edb9b
commit
8b848770dc
@@ -481,6 +481,13 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
# [ledger_history_index]
|
||||
#
|
||||
# If set to greater than 0, the index number of the earliest ledger to
|
||||
# acquire.
|
||||
#
|
||||
#
|
||||
#
|
||||
# [fetch_depth]
|
||||
#
|
||||
# The number of past ledgers to serve to other peers that request historical
|
||||
|
||||
@@ -103,13 +103,14 @@ public:
|
||||
|
||||
// How much history do we want to keep
|
||||
std::uint32_t const ledger_history_;
|
||||
// Acquire past ledgers down to this ledger index
|
||||
std::uint32_t const ledger_history_index_;
|
||||
|
||||
int const ledger_fetch_size_;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
LedgerMasterImp (bool standalone, std::uint32_t fetch_depth,
|
||||
std::uint32_t ledger_history, int ledger_fetch_size, Stoppable& parent,
|
||||
LedgerMasterImp (Config const& config, Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector, beast::Journal journal)
|
||||
: LedgerMaster (parent)
|
||||
, m_journal (journal)
|
||||
@@ -129,11 +130,21 @@ public:
|
||||
, mValidLedgerClose (0)
|
||||
, mValidLedgerSeq (0)
|
||||
, mBuildingLedgerSeq (0)
|
||||
, standalone_ (standalone)
|
||||
, fetch_depth_ (getApp().getSHAMapStore().clampFetchDepth (fetch_depth))
|
||||
, ledger_history_ (ledger_history)
|
||||
, ledger_fetch_size_ (ledger_fetch_size)
|
||||
, standalone_ (config.RUN_STANDALONE)
|
||||
, fetch_depth_ (getApp ().getSHAMapStore ().clampFetchDepth (config.FETCH_DEPTH))
|
||||
, ledger_history_ (config.LEDGER_HISTORY)
|
||||
, ledger_history_index_ (config.LEDGER_HISTORY_INDEX)
|
||||
, ledger_fetch_size_ (config.getSize (siLedgerFetch))
|
||||
{
|
||||
if (ledger_history_index_ != 0 &&
|
||||
config.nodeDatabase["online_delete"].isNotEmpty () &&
|
||||
config.nodeDatabase["online_delete"].getIntValue () > 0)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "[node_db] online_delete option and [ledger_history_index]"
|
||||
" cannot be configured at the same time.";
|
||||
throw std::runtime_error (ss.str ());
|
||||
}
|
||||
}
|
||||
|
||||
~LedgerMasterImp ()
|
||||
@@ -947,7 +958,8 @@ public:
|
||||
}
|
||||
WriteLog (lsTRACE, LedgerMaster) << "tryAdvance discovered missing " << missing;
|
||||
if ((missing != RangeSet::absent) && (missing > 0) &&
|
||||
shouldAcquire(mValidLedgerSeq, ledger_history_, missing) &&
|
||||
shouldAcquire (mValidLedgerSeq, ledger_history_,
|
||||
ledger_history_index_, missing) &&
|
||||
((mFillInProgress == 0) || (missing > mFillInProgress)))
|
||||
{
|
||||
WriteLog (lsTRACE, LedgerMaster) << "advanceThread should acquire";
|
||||
@@ -1546,27 +1558,27 @@ LedgerMaster::~LedgerMaster ()
|
||||
{
|
||||
}
|
||||
|
||||
bool LedgerMaster::shouldAcquire (
|
||||
std::uint32_t currentLedger, std::uint32_t ledgerHistory, std::uint32_t candidateLedger)
|
||||
bool LedgerMaster::shouldAcquire (std::uint32_t currentLedger,
|
||||
std::uint32_t ledgerHistory, std::uint32_t ledgerHistoryIndex,
|
||||
std::uint32_t candidateLedger)
|
||||
{
|
||||
bool ret;
|
||||
bool ret (candidateLedger >= currentLedger ||
|
||||
(ledgerHistoryIndex != 0 && candidateLedger >= ledgerHistoryIndex) ||
|
||||
(currentLedger - candidateLedger) <= ledgerHistory);
|
||||
|
||||
if (candidateLedger >= currentLedger)
|
||||
ret = true;
|
||||
else
|
||||
ret = (currentLedger - candidateLedger) <= ledgerHistory;
|
||||
|
||||
WriteLog (lsTRACE, LedgerMaster) << "Missing ledger " << candidateLedger << (ret ? " should" : " should NOT") << " be acquired";
|
||||
WriteLog (lsTRACE, LedgerMaster)
|
||||
<< "Missing ledger "
|
||||
<< candidateLedger
|
||||
<< (ret ? " should" : " should NOT")
|
||||
<< " be acquired";
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::unique_ptr <LedgerMaster>
|
||||
make_LedgerMaster (bool standalone, std::uint32_t fetch_depth,
|
||||
std::uint32_t ledger_history, int ledger_fetch_size, beast::Stoppable& parent,
|
||||
make_LedgerMaster (Config const& config, beast::Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector, beast::Journal journal)
|
||||
{
|
||||
return std::make_unique <LedgerMasterImp> (standalone, fetch_depth,
|
||||
ledger_history, ledger_fetch_size, parent, collector, journal);
|
||||
return std::make_unique <LedgerMasterImp> (config, parent, collector, journal);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <ripple/app/ledger/LedgerEntrySet.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/RippleLedgerHash.h>
|
||||
#include <ripple/core/Config.h>
|
||||
#include <beast/insight/Collector.h>
|
||||
#include <beast/threads/Stoppable.h>
|
||||
#include <beast/threads/UnlockGuard.h>
|
||||
@@ -150,7 +151,8 @@ public:
|
||||
virtual beast::PropertyStream::Source& getPropertySource () = 0;
|
||||
|
||||
static bool shouldAcquire (std::uint32_t currentLedgerID,
|
||||
std::uint32_t ledgerHistory, std::uint32_t targetLedger);
|
||||
std::uint32_t ledgerHistory, std::uint32_t ledgerHistoryIndex,
|
||||
std::uint32_t targetLedger);
|
||||
|
||||
virtual void clearPriorLedgers (LedgerIndex seq) = 0;
|
||||
|
||||
@@ -158,8 +160,7 @@ public:
|
||||
};
|
||||
|
||||
std::unique_ptr <LedgerMaster>
|
||||
make_LedgerMaster (bool standalone, std::uint32_t fetch_depth,
|
||||
std::uint32_t ledger_history, int ledger_fetch_size, beast::Stoppable& parent,
|
||||
make_LedgerMaster (Config const& config, beast::Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector, beast::Journal journal);
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -291,9 +291,7 @@ public:
|
||||
, m_pathRequests (new PathRequests (
|
||||
m_logs.journal("PathRequest"), m_collectorManager->collector ()))
|
||||
|
||||
, m_ledgerMaster (make_LedgerMaster (getConfig ().RUN_STANDALONE,
|
||||
getConfig ().FETCH_DEPTH, getConfig ().LEDGER_HISTORY,
|
||||
getConfig ().getSize (siLedgerFetch), *m_jobQueue,
|
||||
, m_ledgerMaster (make_LedgerMaster (getConfig (), *m_jobQueue,
|
||||
m_collectorManager->collector (), m_logs.journal("LedgerMaster")))
|
||||
|
||||
// VFALCO NOTE must come before NetworkOPs to prevent a crash due
|
||||
|
||||
@@ -344,6 +344,7 @@ int run (int argc, char** argv)
|
||||
{
|
||||
getConfig ().RUN_STANDALONE = true;
|
||||
getConfig ().LEDGER_HISTORY = 0;
|
||||
getConfig ().LEDGER_HISTORY_INDEX = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -291,6 +291,7 @@ public:
|
||||
|
||||
// Node storage configuration
|
||||
std::uint32_t LEDGER_HISTORY;
|
||||
std::uint32_t LEDGER_HISTORY_INDEX;
|
||||
std::uint32_t FETCH_DEPTH;
|
||||
int NODE_SIZE;
|
||||
|
||||
@@ -310,7 +311,7 @@ public:
|
||||
public:
|
||||
Config ();
|
||||
|
||||
int getSize (SizedItemName);
|
||||
int getSize (SizedItemName) const;
|
||||
void setup (std::string const& strConf, bool bQuiet);
|
||||
void load ();
|
||||
};
|
||||
|
||||
@@ -43,6 +43,7 @@ struct ConfigSection
|
||||
#define SECTION_FEE_OWNER_RESERVE "fee_owner_reserve"
|
||||
#define SECTION_FETCH_DEPTH "fetch_depth"
|
||||
#define SECTION_LEDGER_HISTORY "ledger_history"
|
||||
#define SECTION_LEDGER_HISTORY_INDEX "ledger_history_index"
|
||||
#define SECTION_INSIGHT "insight"
|
||||
#define SECTION_IPS "ips"
|
||||
#define SECTION_IPS_FIXED "ips_fixed"
|
||||
|
||||
@@ -249,6 +249,7 @@ Config::Config ()
|
||||
FEE_CONTRACT_OPERATION = DEFAULT_FEE_OPERATION;
|
||||
|
||||
LEDGER_HISTORY = 256;
|
||||
LEDGER_HISTORY_INDEX = 0;
|
||||
FETCH_DEPTH = 1000000000;
|
||||
|
||||
// An explanation of these magical values would be nice.
|
||||
@@ -584,6 +585,11 @@ void Config::load ()
|
||||
else
|
||||
LEDGER_HISTORY = beast::lexicalCastThrow <std::uint32_t> (strTemp);
|
||||
}
|
||||
if (getSingleSection(secConfig, SECTION_LEDGER_HISTORY_INDEX, strTemp))
|
||||
{
|
||||
LEDGER_HISTORY_INDEX = beast::lexicalCastThrow <std::uint32_t>(strTemp);
|
||||
}
|
||||
|
||||
if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp))
|
||||
{
|
||||
boost::to_lower (strTemp);
|
||||
@@ -628,7 +634,7 @@ void Config::load ()
|
||||
}
|
||||
}
|
||||
|
||||
int Config::getSize (SizedItemName item)
|
||||
int Config::getSize (SizedItemName item) const
|
||||
{
|
||||
SizedItem sizeTable[] = // tiny small medium large huge
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user