From 5d6ea3d75f1a7e1b1460d730c42249ffd7c311bb Mon Sep 17 00:00:00 2001 From: Miguel Portilla Date: Tue, 27 Jan 2015 16:29:29 -0500 Subject: [PATCH] Combine history_ledger_index and online_delete (RIPD-774) --- doc/rippled-example.cfg | 7 ------- src/ripple/app/ledger/LedgerMaster.cpp | 22 +++++----------------- src/ripple/app/main/Main.cpp | 1 - src/ripple/app/misc/SHAMapStoreImp.cpp | 5 +++-- src/ripple/app/misc/SHAMapStoreImp.h | 3 ++- src/ripple/core/Config.h | 1 - src/ripple/core/ConfigSections.h | 1 - src/ripple/core/impl/Config.cpp | 5 ----- 8 files changed, 10 insertions(+), 35 deletions(-) diff --git a/doc/rippled-example.cfg b/doc/rippled-example.cfg index 9841cff15e..47b5516a3a 100644 --- a/doc/rippled-example.cfg +++ b/doc/rippled-example.cfg @@ -481,13 +481,6 @@ # # # -# [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 diff --git a/src/ripple/app/ledger/LedgerMaster.cpp b/src/ripple/app/ledger/LedgerMaster.cpp index 422f291133..6432ecdca6 100644 --- a/src/ripple/app/ledger/LedgerMaster.cpp +++ b/src/ripple/app/ledger/LedgerMaster.cpp @@ -103,8 +103,6 @@ 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_; @@ -133,18 +131,8 @@ public: , 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 () @@ -959,7 +947,7 @@ public: WriteLog (lsTRACE, LedgerMaster) << "tryAdvance discovered missing " << missing; if ((missing != RangeSet::absent) && (missing > 0) && shouldAcquire (mValidLedgerSeq, ledger_history_, - ledger_history_index_, missing) && + getApp ().getSHAMapStore ().getCanDelete (), missing) && ((mFillInProgress == 0) || (missing > mFillInProgress))) { WriteLog (lsTRACE, LedgerMaster) << "advanceThread should acquire"; @@ -1558,12 +1546,12 @@ LedgerMaster::~LedgerMaster () { } -bool LedgerMaster::shouldAcquire (std::uint32_t currentLedger, - std::uint32_t ledgerHistory, std::uint32_t ledgerHistoryIndex, - std::uint32_t candidateLedger) +bool LedgerMaster::shouldAcquire (std::uint32_t const currentLedger, + std::uint32_t const ledgerHistory, std::uint32_t const ledgerHistoryIndex, + std::uint32_t const candidateLedger) { bool ret (candidateLedger >= currentLedger || - (ledgerHistoryIndex != 0 && candidateLedger >= ledgerHistoryIndex) || + candidateLedger > ledgerHistoryIndex || (currentLedger - candidateLedger) <= ledgerHistory); WriteLog (lsTRACE, LedgerMaster) diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index 487ef66111..784ca5bd04 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -344,7 +344,6 @@ int run (int argc, char** argv) { getConfig ().RUN_STANDALONE = true; getConfig ().LEDGER_HISTORY = 0; - getConfig ().LEDGER_HISTORY_INDEX = 0; } } diff --git a/src/ripple/app/misc/SHAMapStoreImp.cpp b/src/ripple/app/misc/SHAMapStoreImp.cpp index 9c2d6f7f00..83531abf44 100644 --- a/src/ripple/app/misc/SHAMapStoreImp.cpp +++ b/src/ripple/app/misc/SHAMapStoreImp.cpp @@ -302,6 +302,9 @@ SHAMapStoreImp::run() transactionDb_ = &getApp().getTxnDB(); ledgerDb_ = &getApp().getLedgerDB(); + if (setup_.advisoryDelete) + canDelete_ = state_db_.getCanDelete (); + while (1) { healthy_ = true; @@ -326,8 +329,6 @@ SHAMapStoreImp::run() lastRotated = validatedSeq; state_db_.setLastRotated (lastRotated); } - if (setup_.advisoryDelete) - canDelete_ = state_db_.getCanDelete(); // will delete up to (not including) lastRotated) if (validatedSeq >= lastRotated + setup_.deleteInterval diff --git a/src/ripple/app/misc/SHAMapStoreImp.h b/src/ripple/app/misc/SHAMapStoreImp.h index 8e3074af56..e8c6b928cf 100644 --- a/src/ripple/app/misc/SHAMapStoreImp.h +++ b/src/ripple/app/misc/SHAMapStoreImp.h @@ -132,7 +132,8 @@ public: LedgerIndex setCanDelete (LedgerIndex seq) override { - canDelete_ = seq; + if (setup_.advisoryDelete) + canDelete_ = seq; return state_db_.setCanDelete (seq); } diff --git a/src/ripple/core/Config.h b/src/ripple/core/Config.h index 168f7ce860..2a4771f6a2 100644 --- a/src/ripple/core/Config.h +++ b/src/ripple/core/Config.h @@ -291,7 +291,6 @@ public: // Node storage configuration std::uint32_t LEDGER_HISTORY; - std::uint32_t LEDGER_HISTORY_INDEX; std::uint32_t FETCH_DEPTH; int NODE_SIZE; diff --git a/src/ripple/core/ConfigSections.h b/src/ripple/core/ConfigSections.h index f4bb70fea9..d1ece80faf 100644 --- a/src/ripple/core/ConfigSections.h +++ b/src/ripple/core/ConfigSections.h @@ -44,7 +44,6 @@ 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" diff --git a/src/ripple/core/impl/Config.cpp b/src/ripple/core/impl/Config.cpp index 371a335f43..45ad36514f 100644 --- a/src/ripple/core/impl/Config.cpp +++ b/src/ripple/core/impl/Config.cpp @@ -248,7 +248,6 @@ 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,10 +583,6 @@ void Config::load () else LEDGER_HISTORY = beast::lexicalCastThrow (strTemp); } - if (getSingleSection(secConfig, SECTION_LEDGER_HISTORY_INDEX, strTemp)) - { - LEDGER_HISTORY_INDEX = beast::lexicalCastThrow (strTemp); - } if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp)) {