From 75bed5efcfe7b3423ff903483c3e9045df22fbc8 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 19 Oct 2015 14:32:45 -0700 Subject: [PATCH] Permit pathfinding to be disabled. (RIPD-271) If you do not need pathfinding, you can disable it and save some resources by setting path_search_max to zero in your config file. --- doc/rippled-example.cfg | 3 +++ src/ripple/app/ledger/OrderBookDB.cpp | 12 +++++++++++- src/ripple/rpc/handlers/PathFind.cpp | 3 +++ src/ripple/rpc/handlers/RipplePathFind.cpp | 3 +++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/rippled-example.cfg b/doc/rippled-example.cfg index bf5644f805..6bbb5b05c2 100644 --- a/doc/rippled-example.cfg +++ b/doc/rippled-example.cfg @@ -527,6 +527,9 @@ # [path_search_max] # When searching for paths, the minimum and maximum search aggressiveness. # +# If you do not need pathfinding, you can set path_search_max to zero to +# disable it and avoid some expensive bookkeeping. +# # The default for 'path_search_fast' is 2. The default for 'path_search_max' is 10. # # [path_search_old] diff --git a/src/ripple/app/ledger/OrderBookDB.cpp b/src/ripple/app/ledger/OrderBookDB.cpp index 8ffff6822c..103c2de2ca 100644 --- a/src/ripple/app/ledger/OrderBookDB.cpp +++ b/src/ripple/app/ledger/OrderBookDB.cpp @@ -66,7 +66,11 @@ void OrderBookDB::setup( mSeq = seq; } - if (app_.config().RUN_STANDALONE) + if (app_.config().PATH_SEARCH_MAX == 0) + { + // nothing to do + } + else if (app_.config().RUN_STANDALONE) update(ledger); else app_.getJobQueue().addJob( @@ -84,6 +88,12 @@ void OrderBookDB::update( JLOG (j_.debug) << "OrderBookDB::update>"; + if (app_.config().PATH_SEARCH_MAX == 0) + { + // pathfinding has been disabled + return; + } + // walk through the entire ledger looking for orderbook entries int books = 0; diff --git a/src/ripple/rpc/handlers/PathFind.cpp b/src/ripple/rpc/handlers/PathFind.cpp index 86a345858e..92fe19db93 100644 --- a/src/ripple/rpc/handlers/PathFind.cpp +++ b/src/ripple/rpc/handlers/PathFind.cpp @@ -32,6 +32,9 @@ namespace ripple { Json::Value doPathFind (RPC::Context& context) { + if (context.app.config().PATH_SEARCH_MAX == 0) + return rpcError (rpcNOT_SUPPORTED); + auto lpLedger = context.ledgerMaster.getClosedLedger(); if (!context.params.isMember (jss::subcommand) || diff --git a/src/ripple/rpc/handlers/RipplePathFind.cpp b/src/ripple/rpc/handlers/RipplePathFind.cpp index 8bca768fb1..272624bc70 100644 --- a/src/ripple/rpc/handlers/RipplePathFind.cpp +++ b/src/ripple/rpc/handlers/RipplePathFind.cpp @@ -70,6 +70,9 @@ buildSrcCurrencies(AccountID const& account, // This interface is deprecated. Json::Value doRipplePathFind (RPC::Context& context) { + if (context.app.config().PATH_SEARCH_MAX == 0) + return rpcError (rpcNOT_SUPPORTED); + RPC::LegacyPathFind lpf (context.role == Role::ADMIN, context.app); if (!lpf.isOk ()) return rpcError (rpcTOO_BUSY);