From ecb9e7db262815e0c2753d85e068d7d5ab217f46 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 5 Mar 2013 09:23:11 -0800 Subject: [PATCH] Enforce validation quorum. Default to quorum of 2 if started with --net. --- src/cpp/ripple/Application.cpp | 3 ++- src/cpp/ripple/LedgerMaster.h | 3 +++ src/cpp/ripple/NetworkOPs.cpp | 2 ++ src/cpp/ripple/main.cpp | 7 ++++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cpp/ripple/Application.cpp b/src/cpp/ripple/Application.cpp index 1d6773dcae..4c07f2b2e8 100644 --- a/src/cpp/ripple/Application.cpp +++ b/src/cpp/ripple/Application.cpp @@ -151,7 +151,7 @@ void Application::setup() else startNewLedger(); - mOrderBookDB.setup(theApp->getLedgerMaster().getCurrentLedger()); // TODO: We need to update this if the ledger jumps + mOrderBookDB.setup(theApp->getLedgerMaster().getCurrentLedger()); // // Begin validation and ip maintenance. @@ -168,6 +168,7 @@ void Application::setup() mValidations.tune(theConfig.getSize(siValidationsSize), theConfig.getSize(siValidationsAge)); mHashedObjectStore.tune(theConfig.getSize(siNodeCacheSize), theConfig.getSize(siNodeCacheAge)); mLedgerMaster.tune(theConfig.getSize(siLedgerSize), theConfig.getSize(siLedgerAge)); + mLedgerMaster.setMinValidations(theConfig.VALIDATION_QUORUM); // // Allow peer connections. diff --git a/src/cpp/ripple/LedgerMaster.h b/src/cpp/ripple/LedgerMaster.h index c79c7e4702..b6665ff89c 100644 --- a/src/cpp/ripple/LedgerMaster.h +++ b/src/cpp/ripple/LedgerMaster.h @@ -77,6 +77,9 @@ public: TER doTransaction(SerializedTransaction::ref txn, TransactionEngineParams params, bool& didApply); + int getMinValidations() { return mMinValidations; } + void setMinValidations(int v) { mMinValidations = v; } + void pushLedger(Ledger::ref newLedger); void pushLedger(Ledger::ref newLCL, Ledger::ref newOL, bool fromConsensus); void storeLedger(Ledger::ref); diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 0b39fd9b64..44f8086a63 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -1189,6 +1189,8 @@ Json::Value NetworkOPs::getServerInfo(bool human, bool admin) if (mNeedNetworkLedger) info["network_ledger"] = "waiting"; + info["validation_quorum"] = mLedgerMaster->getMinValidations(); + if (admin) { if (theConfig.VALIDATION_PUB.isValid()) diff --git a/src/cpp/ripple/main.cpp b/src/cpp/ripple/main.cpp index 15783f8afb..a69c9629eb 100644 --- a/src/cpp/ripple/main.cpp +++ b/src/cpp/ripple/main.cpp @@ -227,7 +227,12 @@ int main(int argc, char* argv[]) { theConfig.START_UP = Config::LOAD; } - else if (vm.count("net")) theConfig.START_UP = Config::NETWORK; + else if (vm.count("net")) + { + theConfig.START_UP = Config::NETWORK; + if (theConfig.VALIDATION_QUORUM < 2) + theConfig.VALIDATION_QUORUM = 2; + } if (iResult) {