Allow the "quorum" command line option to lock the quorum

This commit is contained in:
JoelKatz
2015-09-21 12:03:58 -07:00
committed by Vinnie Falco
parent 938b2fed7c
commit 3c52fdfabe
5 changed files with 12 additions and 5 deletions

View File

@@ -101,7 +101,7 @@ public:
virtual int getMinValidations () = 0; virtual int getMinValidations () = 0;
virtual void setMinValidations (int v) = 0; virtual void setMinValidations (int v, bool strict) = 0;
virtual std::uint32_t getEarliestFetch () = 0; virtual std::uint32_t getEarliestFetch () = 0;

View File

@@ -105,6 +105,7 @@ public:
std::unique_ptr <LedgerCleaner> mLedgerCleaner; std::unique_ptr <LedgerCleaner> mLedgerCleaner;
int mMinValidations; // The minimum validations to publish a ledger. int mMinValidations; // The minimum validations to publish a ledger.
bool mStrictValCount; // Don't raise the minimum
uint256 mLastValidateHash; uint256 mLastValidateHash;
std::uint32_t mLastValidateSeq; std::uint32_t mLastValidateSeq;
@@ -153,6 +154,7 @@ public:
, mLedgerCleaner (make_LedgerCleaner ( , mLedgerCleaner (make_LedgerCleaner (
app, *this, app_.journal("LedgerCleaner"))) app, *this, app_.journal("LedgerCleaner")))
, mMinValidations (0) , mMinValidations (0)
, mStrictValCount (false)
, mLastValidateSeq (0) , mLastValidateSeq (0)
, mAdvanceThread (false) , mAdvanceThread (false)
, mAdvanceWork (false) , mAdvanceWork (false)
@@ -744,7 +746,7 @@ public:
if (seq > mLastValidLedger.second) if (seq > mLastValidLedger.second)
mLastValidLedger = std::make_pair (hash, seq); mLastValidLedger = std::make_pair (hash, seq);
if (mMinValidations < (valCount/2 + 1)) if (!mStrictValCount && (mMinValidations < (valCount/2 + 1)))
{ {
mMinValidations = (valCount/2 + 1); mMinValidations = (valCount/2 + 1);
JLOG (m_journal.info) JLOG (m_journal.info)
@@ -1355,10 +1357,12 @@ public:
return mMinValidations; 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; mMinValidations = v;
mStrictValCount = strict;
} }
std::string getCompleteLedgers () override std::string getCompleteLedgers () override

View File

@@ -832,7 +832,8 @@ public:
config_->section (SECTION_AMENDMENTS)); config_->section (SECTION_AMENDMENTS));
initializePathfinding (); initializePathfinding ();
m_ledgerMaster->setMinValidations (config_->VALIDATION_QUORUM); m_ledgerMaster->setMinValidations (
config_->VALIDATION_QUORUM, config_->LOCK_QUORUM);
auto const startUp = config_->START_UP; auto const startUp = config_->START_UP;
if (startUp == Config::FRESH) if (startUp == Config::FRESH)

View File

@@ -459,6 +459,7 @@ int run (int argc, char** argv)
try try
{ {
config->VALIDATION_QUORUM = vm["quorum"].as <int> (); config->VALIDATION_QUORUM = vm["quorum"].as <int> ();
config->LOCK_QUORUM = true;
if (config->VALIDATION_QUORUM < 0) if (config->VALIDATION_QUORUM < 0)
throw std::domain_error (""); throw std::domain_error ("");

View File

@@ -206,6 +206,7 @@ public:
// Note: The following parameters do not relate to the UNL or trust at all // 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 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 int VALIDATION_QUORUM = 1; // Minimum validations to consider ledger authoritative
bool LOCK_QUORUM = false; // Do not raise the quorum
// Peer networking parameters // Peer networking parameters
bool PEER_PRIVATE = false; // True to ask peers not to relay current IP. bool PEER_PRIVATE = false; // True to ask peers not to relay current IP.