From 3c52fdfabe5a9037d78f9dfa5044221cc272aadd Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 21 Sep 2015 12:03:58 -0700 Subject: [PATCH] Allow the "quorum" command line option to lock the quorum --- src/ripple/app/ledger/LedgerMaster.h | 2 +- src/ripple/app/ledger/impl/LedgerMaster.cpp | 10 +++++++--- src/ripple/app/main/Application.cpp | 3 ++- src/ripple/app/main/Main.cpp | 1 + src/ripple/core/Config.h | 1 + 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ripple/app/ledger/LedgerMaster.h b/src/ripple/app/ledger/LedgerMaster.h index 60ed708cdd..223c813975 100644 --- a/src/ripple/app/ledger/LedgerMaster.h +++ b/src/ripple/app/ledger/LedgerMaster.h @@ -101,7 +101,7 @@ public: virtual int getMinValidations () = 0; - virtual void setMinValidations (int v) = 0; + virtual void setMinValidations (int v, bool strict) = 0; virtual std::uint32_t getEarliestFetch () = 0; diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index b81911feff..2f60525f4b 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -105,6 +105,7 @@ public: std::unique_ptr mLedgerCleaner; int mMinValidations; // The minimum validations to publish a ledger. + bool mStrictValCount; // Don't raise the minimum uint256 mLastValidateHash; std::uint32_t mLastValidateSeq; @@ -153,6 +154,7 @@ public: , mLedgerCleaner (make_LedgerCleaner ( app, *this, app_.journal("LedgerCleaner"))) , mMinValidations (0) + , mStrictValCount (false) , mLastValidateSeq (0) , mAdvanceThread (false) , mAdvanceWork (false) @@ -744,7 +746,7 @@ public: if (seq > mLastValidLedger.second) mLastValidLedger = std::make_pair (hash, seq); - if (mMinValidations < (valCount/2 + 1)) + if (!mStrictValCount && (mMinValidations < (valCount/2 + 1))) { mMinValidations = (valCount/2 + 1); JLOG (m_journal.info) @@ -1355,10 +1357,12 @@ public: return mMinValidations; } - void setMinValidations (int v) override + void setMinValidations (int v, bool strict) override { - JLOG (m_journal.info) << "Validation quorum: " << v; + JLOG (m_journal.info) << "Validation quorum: " << v + << (strict ? " strict" : ""); mMinValidations = v; + mStrictValCount = strict; } std::string getCompleteLedgers () override diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 32bf65c571..d2294402ab 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -832,7 +832,8 @@ public: config_->section (SECTION_AMENDMENTS)); initializePathfinding (); - m_ledgerMaster->setMinValidations (config_->VALIDATION_QUORUM); + m_ledgerMaster->setMinValidations ( + config_->VALIDATION_QUORUM, config_->LOCK_QUORUM); auto const startUp = config_->START_UP; if (startUp == Config::FRESH) diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index f2ceece46f..abea442993 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -459,6 +459,7 @@ int run (int argc, char** argv) try { config->VALIDATION_QUORUM = vm["quorum"].as (); + config->LOCK_QUORUM = true; if (config->VALIDATION_QUORUM < 0) throw std::domain_error (""); diff --git a/src/ripple/core/Config.h b/src/ripple/core/Config.h index e15fd6b657..29cdda4309 100644 --- a/src/ripple/core/Config.h +++ b/src/ripple/core/Config.h @@ -206,6 +206,7 @@ public: // Note: The following parameters do not relate to the UNL or trust at all std::size_t NETWORK_QUORUM = 0; // Minimum number of nodes to consider the network present int VALIDATION_QUORUM = 1; // Minimum validations to consider ledger authoritative + bool LOCK_QUORUM = false; // Do not raise the quorum // Peer networking parameters bool PEER_PRIVATE = false; // True to ask peers not to relay current IP.