Use accessor function for theConfig

This commit is contained in:
Vinnie Falco
2013-07-24 07:28:11 -07:00
parent c27294e0f0
commit 788817e55c
30 changed files with 257 additions and 263 deletions

View File

@@ -6,13 +6,10 @@ Items marked '*' can be handled by third parties.
Vinnie's Short List (Changes day to day)
- Review boost::asio wrappers and consolidation of network code in ripple_net
- Make theConfig a SharedSingleton to prevent leak warnings
- Refactor Section code into ConfigFile
- Improved Mutex to track deadlocks
- Finish unit tests and code for Validators
- Import beast::db and use it in SQliteBackend
* Convert some Ripple boost unit tests to Beast.
- Move all code into modules/
- Work on KeyvaDB
--------------------------------------------------------------------------------

View File

@@ -12,7 +12,7 @@ SETUP_LOG (LedgerConsensus)
LedgerConsensus::LedgerConsensus (uint256 const& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime)
: mState (lcsPRE_CLOSE), mCloseTime (closeTime), mPrevLedgerHash (prevLCLHash), mPreviousLedger (previousLedger),
mValPublic (theConfig.VALIDATION_PUB), mValPrivate (theConfig.VALIDATION_PRIV), mConsensusFail (false),
mValPublic (getConfig ().VALIDATION_PUB), mValPrivate (getConfig ().VALIDATION_PRIV), mConsensusFail (false),
mCurrentMSeconds (0), mClosePercent (0), mHaveCloseTimeConsensus (false),
mConsensusStartTime (boost::posix_time::microsec_clock::universal_time ())
{
@@ -226,7 +226,7 @@ void LedgerConsensus::takeInitialPosition (Ledger& initialLedger)
{
SHAMap::pointer initialSet;
if ((theConfig.RUN_STANDALONE || (mProposing && mHaveCorrectLCL))
if ((getConfig ().RUN_STANDALONE || (mProposing && mHaveCorrectLCL))
&& ((mPreviousLedger->getLedgerSeq () % 256) == 0))
{
// previous ledger was flag ledger

View File

@@ -15,7 +15,7 @@ namespace Script
int Operation::getFee ()
{
return (theConfig.FEE_CONTRACT_OPERATION);
return (getConfig ().FEE_CONTRACT_OPERATION);
}
}

View File

@@ -14,10 +14,10 @@ DatabaseCon::DatabaseCon (const std::string& strName, const char* initStrings[],
// responsibility to pass in the path. Add a member function to Application
// or Config to compute this path.
//
boost::filesystem::path pPath = (theConfig.RUN_STANDALONE &&
((theConfig.START_UP != Config::LOAD) && (theConfig.START_UP != Config::REPLAY)))
boost::filesystem::path pPath = (getConfig ().RUN_STANDALONE &&
((getConfig ().START_UP != Config::LOAD) && (getConfig ().START_UP != Config::REPLAY)))
? "" // Use temporary files.
: (theConfig.DATA_DIR / strName); // Use regular db files.
: (getConfig ().DATA_DIR / strName); // Use regular db files.
mDatabase = new SqliteDatabase (pPath.string ().c_str ());
mDatabase->connect ();

View File

@@ -607,7 +607,7 @@ void Ledger::saveAcceptedLedger (Job&, bool fromConsensus)
mCloseResolution % mCloseFlags % mAccountHash.GetHex () % mTransHash.GetHex ()));
}
if (!fromConsensus && (theConfig.NODE_SIZE < 2)) // tiny or small
if (!fromConsensus && (getConfig ().NODE_SIZE < 2)) // tiny or small
dropCache ();
if (getApp().getJobQueue ().getJobCountTotal (jtPUBOLDLEDGER) < 2)
@@ -1845,10 +1845,10 @@ void Ledger::initializeFees ()
void Ledger::updateFees ()
{
mBaseFee = theConfig.FEE_DEFAULT;
mBaseFee = getConfig ().FEE_DEFAULT;
mReferenceFeeUnits = 10;
mReserveBase = theConfig.FEE_ACCOUNT_RESERVE;
mReserveIncrement = theConfig.FEE_OWNER_RESERVE;
mReserveBase = getConfig ().FEE_ACCOUNT_RESERVE;
mReserveIncrement = getConfig ().FEE_OWNER_RESERVE;
LedgerStateParms p = lepNONE;
SLE::pointer sle = getASNode (p, Ledger::getLedgerFeeIndex (), ltFEE_SETTINGS);

View File

@@ -357,7 +357,7 @@ bool LedgerMaster::acquireMissingLedger (Ledger::ref origLedger, uint256 const&
getApp().getIOService ().post (BIND_TYPE (&LedgerMaster::missingAcquireComplete, this, mMissingLedger));
}
int fetchMax = theConfig.getSize (siLedgerFetch);
int fetchMax = getConfig ().getSize (siLedgerFetch);
int timeoutCount;
int fetchCount = getApp().getInboundLedgers ().getFetchCount (timeoutCount);
@@ -480,7 +480,7 @@ void LedgerMaster::resumeAcquiring ()
if (mMissingLedger && mMissingLedger->isDone ())
mMissingLedger.reset ();
if (mMissingLedger || !theConfig.LEDGER_HISTORY)
if (mMissingLedger || !getConfig ().LEDGER_HISTORY)
{
CondLog (mMissingLedger, lsDEBUG, LedgerMaster) << "Fetch already in progress, not resuming";
return;
@@ -494,7 +494,7 @@ void LedgerMaster::resumeAcquiring ()
return;
}
if (shouldAcquire (mCurrentLedger->getLedgerSeq (), theConfig.LEDGER_HISTORY, prevMissing))
if (shouldAcquire (mCurrentLedger->getLedgerSeq (), getConfig ().LEDGER_HISTORY, prevMissing))
{
WriteLog (lsTRACE, LedgerMaster) << "Resuming at " << prevMissing;
assert (!mCompleteLedgers.hasValue (prevMissing));
@@ -581,7 +581,7 @@ void LedgerMaster::setFullLedger (Ledger::pointer ledger)
mMissingLedger.reset ();
}
if (mMissingLedger || !theConfig.LEDGER_HISTORY)
if (mMissingLedger || !getConfig ().LEDGER_HISTORY)
{
CondLog (mMissingLedger, lsDEBUG, LedgerMaster) << "Fetch already in progress, " << mMissingLedger->getTimeouts () << " timeouts";
return;
@@ -596,7 +596,7 @@ void LedgerMaster::setFullLedger (Ledger::pointer ledger)
// see if there's a ledger gap we need to fill
if (!mCompleteLedgers.hasValue (ledger->getLedgerSeq () - 1))
{
if (!shouldAcquire (mCurrentLedger->getLedgerSeq (), theConfig.LEDGER_HISTORY, ledger->getLedgerSeq () - 1))
if (!shouldAcquire (mCurrentLedger->getLedgerSeq (), getConfig ().LEDGER_HISTORY, ledger->getLedgerSeq () - 1))
{
WriteLog (lsTRACE, LedgerMaster) << "Don't need any ledgers";
return;
@@ -615,7 +615,7 @@ void LedgerMaster::setFullLedger (Ledger::pointer ledger)
return;
}
if (shouldAcquire (mCurrentLedger->getLedgerSeq (), theConfig.LEDGER_HISTORY, prevMissing))
if (shouldAcquire (mCurrentLedger->getLedgerSeq (), getConfig ().LEDGER_HISTORY, prevMissing))
{
WriteLog (lsDEBUG, LedgerMaster) << "Ledger " << prevMissing << " is needed";
assert (!mCompleteLedgers.hasValue (prevMissing));
@@ -662,7 +662,7 @@ void LedgerMaster::checkAccept (uint256 const& hash, uint32 seq)
minVal = val;
}
if (theConfig.RUN_STANDALONE)
if (getConfig ().RUN_STANDALONE)
minVal = 0;
else if (getApp().getOPs ().isNeedNetworkLedger ())
minVal = 1;

View File

@@ -37,7 +37,7 @@ uint256 LedgerProposal::getSigningHash () const
{
Serializer s ((32 + 32 + 32 + 256 + 256) / 8);
s.add32 (theConfig.SIGN_PROPOSAL);
s.add32 (getConfig ().SIGN_PROPOSAL);
s.add32 (mProposeSeq);
s.add32 (mCloseTime);
s.add256 (mPreviousLedger);

View File

@@ -52,7 +52,7 @@ void SerializedValidation::sign (uint256& signingHash, const RippleAddress& raPr
uint256 SerializedValidation::getSigningHash () const
{
return STObject::getSigningHash (theConfig.SIGN_VALIDATION);
return STObject::getSigningHash (getConfig ().SIGN_VALIDATION);
}
uint256 SerializedValidation::getLedgerHash () const

View File

@@ -25,8 +25,6 @@ public:
return new ApplicationImp;
}
class Holder;
ApplicationImp ()
//
// VFALCO NOTE Change this to control whether or not the Application
@@ -42,7 +40,7 @@ public:
//
: SharedSingleton <Application> (SingletonLifetime::neverDestroyed)
#endif
, mIOService ((theConfig.NODE_SIZE >= 2) ? 2 : 1)
, mIOService ((getConfig ().NODE_SIZE >= 2) ? 2 : 1)
, mIOWork (mIOService)
, mNetOps (new NetworkOPs (&mLedgerMaster))
, m_rpcServerHandler (*mNetOps)
@@ -52,8 +50,8 @@ public:
, mJobQueue (mIOService)
// VFALCO New stuff
, m_nodeStore (NodeStore::New (
theConfig.nodeDatabase,
theConfig.ephemeralNodeDatabase,
getConfig ().nodeDatabase,
getConfig ().ephemeralNodeDatabase,
*this))
, m_validators (Validators::New (this))
, mFeatures (IFeatures::New (2 * 7 * 24 * 60 * 60, 200)) // two weeks, 200/256
@@ -374,7 +372,7 @@ static void runIO (boost::asio::io_service& io)
void ApplicationImp::setup ()
{
// VFALCO NOTE: 0 means use heuristics to determine the thread count.
mJobQueue.setThreadCount (0, theConfig.RUN_STANDALONE);
mJobQueue.setThreadCount (0, getConfig ().RUN_STANDALONE);
mSweepTimer.expires_from_now (boost::posix_time::seconds (10));
mSweepTimer.async_wait (BIND_TYPE (&ApplicationImp::sweep, this));
@@ -384,7 +382,7 @@ void ApplicationImp::setup ()
#if ! BEAST_WIN32
#ifdef SIGINT
if (!theConfig.RUN_STANDALONE)
if (!getConfig ().RUN_STANDALONE)
{
struct sigaction sa;
memset (&sa, 0, sizeof (sa));
@@ -397,10 +395,10 @@ void ApplicationImp::setup ()
assert (mTxnDB == NULL);
if (!theConfig.DEBUG_LOGFILE.empty ())
if (!getConfig ().DEBUG_LOGFILE.empty ())
{
// Let debug messages go to the file but only WARNING or higher to regular output (unless verbose)
Log::setLogFile (theConfig.DEBUG_LOGFILE);
Log::setLogFile (getConfig ().DEBUG_LOGFILE);
if (Log::getMinSeverity () > lsDEBUG)
LogPartition::setSeverity (lsDEBUG);
@@ -408,8 +406,8 @@ void ApplicationImp::setup ()
boost::thread (BIND_TYPE (runAux, boost::ref (mAuxService))).detach ();
if (!theConfig.RUN_STANDALONE)
mSNTPClient.init (theConfig.SNTP_SERVERS);
if (!getConfig ().RUN_STANDALONE)
mSNTPClient.init (getConfig ().SNTP_SERVERS);
//
// Construct databases.
@@ -425,41 +423,41 @@ void ApplicationImp::setup ()
leveldb::Options options;
options.create_if_missing = true;
options.block_cache = leveldb::NewLRUCache (theConfig.getSize (siHashNodeDBCache) * 1024 * 1024);
options.block_cache = leveldb::NewLRUCache (getConfig ().getSize (siHashNodeDBCache) * 1024 * 1024);
getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
(theConfig.getSize (siLgrDBCache) * 1024)));
(getConfig ().getSize (siLgrDBCache) * 1024)));
getApp().getTxnDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
(theConfig.getSize (siTxnDBCache) * 1024)));
(getConfig ().getSize (siTxnDBCache) * 1024)));
mTxnDB->getDB ()->setupCheckpointing (&mJobQueue);
mLedgerDB->getDB ()->setupCheckpointing (&mJobQueue);
if (!theConfig.RUN_STANDALONE)
if (!getConfig ().RUN_STANDALONE)
updateTables ();
mFeatures->addInitialFeatures ();
if (theConfig.START_UP == Config::FRESH)
if (getConfig ().START_UP == Config::FRESH)
{
WriteLog (lsINFO, Application) << "Starting new Ledger";
startNewLedger ();
}
else if ((theConfig.START_UP == Config::LOAD) || (theConfig.START_UP == Config::REPLAY))
else if ((getConfig ().START_UP == Config::LOAD) || (getConfig ().START_UP == Config::REPLAY))
{
WriteLog (lsINFO, Application) << "Loading specified Ledger";
if (!loadOldLedger (theConfig.START_LEDGER, theConfig.START_UP == Config::REPLAY))
if (!loadOldLedger (getConfig ().START_LEDGER, getConfig ().START_UP == Config::REPLAY))
{
getApp().stop ();
exit (-1);
}
}
else if (theConfig.START_UP == Config::NETWORK)
else if (getConfig ().START_UP == Config::NETWORK)
{
// This should probably become the default once we have a stable network
if (!theConfig.RUN_STANDALONE)
if (!getConfig ().RUN_STANDALONE)
mNetOps->needNetworkLedger ();
startNewLedger ();
@@ -478,28 +476,28 @@ void ApplicationImp::setup ()
//
// Set up UNL.
//
if (!theConfig.RUN_STANDALONE)
if (!getConfig ().RUN_STANDALONE)
getUNL ().nodeBootstrap ();
mValidations->tune (theConfig.getSize (siValidationsSize), theConfig.getSize (siValidationsAge));
m_nodeStore->tune (theConfig.getSize (siNodeCacheSize), theConfig.getSize (siNodeCacheAge));
mLedgerMaster.tune (theConfig.getSize (siLedgerSize), theConfig.getSize (siLedgerAge));
mSLECache.setTargetSize (theConfig.getSize (siSLECacheSize));
mSLECache.setTargetAge (theConfig.getSize (siSLECacheAge));
mValidations->tune (getConfig ().getSize (siValidationsSize), getConfig ().getSize (siValidationsAge));
m_nodeStore->tune (getConfig ().getSize (siNodeCacheSize), getConfig ().getSize (siNodeCacheAge));
mLedgerMaster.tune (getConfig ().getSize (siLedgerSize), getConfig ().getSize (siLedgerAge));
mSLECache.setTargetSize (getConfig ().getSize (siSLECacheSize));
mSLECache.setTargetAge (getConfig ().getSize (siSLECacheAge));
mLedgerMaster.setMinValidations (theConfig.VALIDATION_QUORUM);
mLedgerMaster.setMinValidations (getConfig ().VALIDATION_QUORUM);
//
// Allow peer connections.
//
if (!theConfig.RUN_STANDALONE)
if (!getConfig ().RUN_STANDALONE)
{
try
{
mPeerDoor = PeerDoor::New (
theConfig.PEER_IP,
theConfig.PEER_PORT,
theConfig.PEER_SSL_CIPHER_LIST,
getConfig ().PEER_IP,
getConfig ().PEER_PORT,
getConfig ().PEER_SSL_CIPHER_LIST,
mIOService);
}
catch (const std::exception& e)
@@ -518,7 +516,7 @@ void ApplicationImp::setup ()
//
// Allow RPC connections.
//
if (! theConfig.getRpcIP().empty () && theConfig.getRpcPort() != 0)
if (! getConfig ().getRpcIP().empty () && getConfig ().getRpcPort() != 0)
{
try
{
@@ -540,11 +538,11 @@ void ApplicationImp::setup ()
//
// Allow private WS connections.
//
if (!theConfig.WEBSOCKET_IP.empty () && theConfig.WEBSOCKET_PORT)
if (!getConfig ().WEBSOCKET_IP.empty () && getConfig ().WEBSOCKET_PORT)
{
try
{
mWSPrivateDoor = WSDoor::createWSDoor (theConfig.WEBSOCKET_IP, theConfig.WEBSOCKET_PORT, false);
mWSPrivateDoor = WSDoor::createWSDoor (getConfig ().WEBSOCKET_IP, getConfig ().WEBSOCKET_PORT, false);
}
catch (const std::exception& e)
{
@@ -562,11 +560,11 @@ void ApplicationImp::setup ()
//
// Allow public WS connections.
//
if (!theConfig.WEBSOCKET_PUBLIC_IP.empty () && theConfig.WEBSOCKET_PUBLIC_PORT)
if (!getConfig ().WEBSOCKET_PUBLIC_IP.empty () && getConfig ().WEBSOCKET_PUBLIC_PORT)
{
try
{
mWSPublicDoor = WSDoor::createWSDoor (theConfig.WEBSOCKET_PUBLIC_IP, theConfig.WEBSOCKET_PUBLIC_PORT, true);
mWSPublicDoor = WSDoor::createWSDoor (getConfig ().WEBSOCKET_PUBLIC_IP, getConfig ().WEBSOCKET_PUBLIC_PORT, true);
}
catch (const std::exception& e)
{
@@ -584,10 +582,10 @@ void ApplicationImp::setup ()
//
// Begin connecting to network.
//
if (!theConfig.RUN_STANDALONE)
if (!getConfig ().RUN_STANDALONE)
mPeers->start ();
if (theConfig.RUN_STANDALONE)
if (getConfig ().RUN_STANDALONE)
{
WriteLog (lsWARNING, Application) << "Running in standalone mode";
@@ -603,12 +601,12 @@ void ApplicationImp::setup ()
void ApplicationImp::run ()
{
if (theConfig.NODE_SIZE >= 2)
if (getConfig ().NODE_SIZE >= 2)
{
boost::thread (BIND_TYPE (runIO, boost::ref (mIOService))).detach ();
}
if (!theConfig.RUN_STANDALONE)
if (!getConfig ().RUN_STANDALONE)
{
// VFALCO NOTE This seems unnecessary. If we properly refactor the load
// manager then the deadlock detector can just always be "armed"
@@ -642,7 +640,7 @@ void ApplicationImp::run ()
void ApplicationImp::sweep ()
{
boost::filesystem::space_info space = boost::filesystem::space (theConfig.DATA_DIR);
boost::filesystem::space_info space = boost::filesystem::space (getConfig ().DATA_DIR);
// VFALCO TODO Give this magic constant a name and move it into a well documented header
//
@@ -674,7 +672,7 @@ void ApplicationImp::doSweep(Job& j)
SHAMap::sweep (); // VFALCO NOTE SHAMap is/has a singleton?
mNetOps->sweepFetchPack ();
// VFALCO NOTE does the call to sweep() happen on another thread?
mSweepTimer.expires_from_now (boost::posix_time::seconds (theConfig.getSize (siSweepInterval)));
mSweepTimer.expires_from_now (boost::posix_time::seconds (getConfig ().getSize (siSweepInterval)));
mSweepTimer.async_wait (BIND_TYPE (&ApplicationImp::sweep, this));
}
@@ -808,7 +806,7 @@ bool ApplicationImp::loadOldLedger (const std::string& l, bool bReplay)
bool serverOkay (std::string& reason)
{
if (!theConfig.ELB_SUPPORT)
if (!getConfig ().ELB_SUPPORT)
return true;
if (getApp().isShutdown ())
@@ -955,7 +953,7 @@ static void addTxnSeqField ()
void ApplicationImp::updateTables ()
{
if (theConfig.nodeDatabase.size () <= 0)
if (getConfig ().nodeDatabase.size () <= 0)
{
Log (lsFATAL) << "The [node_db] configuration setting has been updated and must be set";
StopSustain ();
@@ -974,9 +972,9 @@ void ApplicationImp::updateTables ()
exit (1);
}
if (theConfig.importNodeDatabase.size () > 0)
if (getConfig ().importNodeDatabase.size () > 0)
{
ScopedPointer <NodeStore> source (NodeStore::New (theConfig.importNodeDatabase));
ScopedPointer <NodeStore> source (NodeStore::New (getConfig ().importNodeDatabase));
WriteLog (lsWARNING, NodeObject) <<
"Node import from '" << source->getName () << "' to '"

View File

@@ -23,7 +23,7 @@ void LocalCredentials::start ()
throw std::runtime_error ("unable to retrieve new node identity.");
}
if (!theConfig.QUIET)
if (!getConfig ().QUIET)
Log::out() << "NodeIdentity: " << mNodePublicKey.humanNodePublic ();
getApp().getUNL ().start ();
@@ -54,10 +54,10 @@ bool LocalCredentials::nodeIdentityLoad ()
bSuccess = true;
}
if (theConfig.NODE_PUB.isValid () && theConfig.NODE_PRIV.isValid ())
if (getConfig ().NODE_PUB.isValid () && getConfig ().NODE_PRIV.isValid ())
{
mNodePublicKey = theConfig.NODE_PUB;
mNodePrivateKey = theConfig.NODE_PRIV;
mNodePublicKey = getConfig ().NODE_PUB;
mNodePrivateKey = getConfig ().NODE_PRIV;
}
return bSuccess;
@@ -66,7 +66,7 @@ bool LocalCredentials::nodeIdentityLoad ()
// Create and store a network identity.
bool LocalCredentials::nodeIdentityCreate ()
{
if (!theConfig.QUIET)
if (!getConfig ().QUIET)
Log::out() << "NodeIdentity: Creating.";
//
@@ -113,7 +113,7 @@ bool LocalCredentials::nodeIdentityCreate ()
% sqlEscape (strDh1024)));
// XXX Check error result.
if (!theConfig.QUIET)
if (!getConfig ().QUIET)
Log::out() << "NodeIdentity: Created.";
return true;

View File

@@ -28,13 +28,13 @@ void startServer ()
//
// Execute start up rpc commands.
//
if (theConfig.RPC_STARTUP.isArray ())
if (getConfig ().RPC_STARTUP.isArray ())
{
for (int i = 0; i != theConfig.RPC_STARTUP.size (); ++i)
for (int i = 0; i != getConfig ().RPC_STARTUP.size (); ++i)
{
const Json::Value& jvCommand = theConfig.RPC_STARTUP[i];
const Json::Value& jvCommand = getConfig ().RPC_STARTUP[i];
if (!theConfig.QUIET)
if (!getConfig ().QUIET)
Log::out() << "Startup RPC: " << jvCommand;
RPCHandler rhHandler (&getApp().getOPs ());
@@ -43,7 +43,7 @@ void startServer ()
LoadType loadType = LT_RPCReference;
Json::Value jvResult = rhHandler.doCommand (jvCommand, RPCHandler::ADMIN, &loadType);
if (!theConfig.QUIET)
if (!getConfig ().QUIET)
Log::out() << "Result: " << jvResult;
}
}
@@ -51,22 +51,6 @@ void startServer ()
getApp().run (); // Blocks till we get a stop RPC.
}
void setupConfigForUnitTests (Config* config)
{
config->nodeDatabase = parseDelimitedKeyValueString ("type=memory");
config->ephemeralNodeDatabase = StringPairArray ();
config->importNodeDatabase = StringPairArray ();
}
bool init_unit_test ()
{
setupConfigForUnitTests (&theConfig);
getApp ();
return true;
}
void printHelp (const po::options_description& desc)
{
using namespace std;
@@ -137,50 +121,42 @@ void printHelp (const po::options_description& desc)
//------------------------------------------------------------------------------
// OUr custom unit test runner
//
class RippleUnitTests : public UnitTests
{
public:
RippleUnitTests ()
{
// VFALCO NOTE It sucks that we have to do this but some
// code demands the Application object exists.
//
// To find out who, just change the 1 to 0
#if 1
setupConfigForUnitTests (&getConfig ());
getApp ();
#endif
setAssertOnFailure (false);
setPassesAreLogged (false);
}
void logMessage (String const& message)
{
Log::out () << message.toStdString ();
}
private:
void setupConfigForUnitTests (Config* config)
{
config->nodeDatabase = parseDelimitedKeyValueString ("type=memory");
config->ephemeralNodeDatabase = StringPairArray ();
config->importNodeDatabase = StringPairArray ();
}
};
//------------------------------------------------------------------------------
/** Run the Beast unit tests.
*/
static void runBeastUnitTests (std::string const& individualTest = "")
{
// VFALCO NOTE It sucks that we have to do this but some
// code demands the Application object exists.
//
// To find out who, just change the #if
#if 1
{
setupConfigForUnitTests (&theConfig);
getApp ();
}
#endif
RippleUnitTests tr;
tr.setAssertOnFailure (false);
tr.setPassesAreLogged (false);
if (individualTest.empty ())
{
tr.runAllTests ();
}
else
{
tr.runTest (individualTest.c_str ());
}
}
//------------------------------------------------------------------------------
int rippleMain (int argc, char** argv)
{
//
@@ -312,7 +288,7 @@ int rippleMain (int argc, char** argv)
if (HaveSustain () &&
!iResult && !vm.count ("parameters") && !vm.count ("fg") && !vm.count ("standalone") && !vm.count ("unittest"))
{
std::string logMe = DoSustain (theConfig.DEBUG_LOGFILE.string());
std::string logMe = DoSustain (getConfig ().DEBUG_LOGFILE.string());
if (!logMe.empty ())
Log (lsWARNING) << logMe;
@@ -335,28 +311,37 @@ int rippleMain (int argc, char** argv)
//
if (vm.count ("unittest"))
{
std::string const test = vm ["unittest"].as <std::string> ();
String const arg = vm ["unittest"].as <std::string> ();
runBeastUnitTests (test);
RippleUnitTests tr;
if (arg == "")
{
tr.runAllTests ();
}
else
{
tr.runTest (arg);
}
return 0;
}
if (!iResult)
{
theConfig.setup (
getConfig ().setup (
vm.count ("conf") ? vm["conf"].as<std::string> () : "", // Config file.
!!vm.count ("testnet"), // Testnet flag.
!!vm.count ("quiet")); // Quiet flag.
if (vm.count ("standalone"))
{
theConfig.RUN_STANDALONE = true;
theConfig.LEDGER_HISTORY = 0;
getConfig ().RUN_STANDALONE = true;
getConfig ().LEDGER_HISTORY = 0;
}
}
if (vm.count ("start")) theConfig.START_UP = Config::FRESH;
if (vm.count ("start")) getConfig ().START_UP = Config::FRESH;
// Handle a one-time import option
//
@@ -364,27 +349,27 @@ int rippleMain (int argc, char** argv)
{
String const optionString (vm ["import"].as <std::string> ());
theConfig.importNodeDatabase = parseDelimitedKeyValueString (optionString);
getConfig ().importNodeDatabase = parseDelimitedKeyValueString (optionString);
}
if (vm.count ("ledger"))
{
theConfig.START_LEDGER = vm["ledger"].as<std::string> ();
getConfig ().START_LEDGER = vm["ledger"].as<std::string> ();
if (vm.count("replay"))
theConfig.START_UP = Config::REPLAY;
getConfig ().START_UP = Config::REPLAY;
else
theConfig.START_UP = Config::LOAD;
getConfig ().START_UP = Config::LOAD;
}
else if (vm.count ("load"))
{
theConfig.START_UP = Config::LOAD;
getConfig ().START_UP = Config::LOAD;
}
else if (vm.count ("net"))
{
theConfig.START_UP = Config::NETWORK;
getConfig ().START_UP = Config::NETWORK;
if (theConfig.VALIDATION_QUORUM < 2)
theConfig.VALIDATION_QUORUM = 2;
if (getConfig ().VALIDATION_QUORUM < 2)
getConfig ().VALIDATION_QUORUM = 2;
}
if (iResult == 0)
@@ -395,7 +380,7 @@ int rippleMain (int argc, char** argv)
//
if (vm.count ("rpc_ip"))
{
theConfig.setRpcIpAndOptionalPort (vm ["rpc_ip"].as <std::string> ());
getConfig ().setRpcIpAndOptionalPort (vm ["rpc_ip"].as <std::string> ());
}
// Override the RPC destination port number
@@ -403,7 +388,7 @@ int rippleMain (int argc, char** argv)
if (vm.count ("rpc_port"))
{
// VFALCO TODO This should be a short.
theConfig.setRpcPort (vm ["rpc_port"].as <int> ());
getConfig ().setRpcPort (vm ["rpc_port"].as <int> ());
}
}

View File

@@ -53,14 +53,14 @@ void NetworkOPs::processNetTimer ()
std::size_t const numPeers = getApp().getPeers ().getPeerVector ().size ();
// do we have sufficient peers? If not, we are disconnected.
if (numPeers < theConfig.NETWORK_QUORUM)
if (numPeers < getConfig ().NETWORK_QUORUM)
{
if (mMode != omDISCONNECTED)
{
setMode (omDISCONNECTED);
WriteLog (lsWARNING, NetworkOPs)
<< "Node count (" << numPeers << ") "
<< "has fallen below quorum (" << theConfig.NETWORK_QUORUM << ").";
<< "has fallen below quorum (" << getConfig ().NETWORK_QUORUM << ").";
}
return;
@@ -1394,8 +1394,8 @@ Json::Value NetworkOPs::getServerInfo (bool human, bool admin)
info ["build_version"] = BuildVersion::getBuildVersion ();
info ["client_version"] = BuildVersion::getClientVersion ();
if (theConfig.TESTNET)
info["testnet"] = theConfig.TESTNET;
if (getConfig ().TESTNET)
info["testnet"] = getConfig ().TESTNET;
info["server_state"] = strOperatingMode ();
@@ -1406,8 +1406,8 @@ Json::Value NetworkOPs::getServerInfo (bool human, bool admin)
if (admin)
{
if (theConfig.VALIDATION_PUB.isValid ())
info["pubkey_validator"] = theConfig.VALIDATION_PUB.humanNodePublic ();
if (getConfig ().VALIDATION_PUB.isValid ())
info["pubkey_validator"] = getConfig ().VALIDATION_PUB.humanNodePublic ();
else
info["pubkey_validator"] = "none";
}
@@ -1982,11 +1982,11 @@ bool NetworkOPs::subServer (InfoSub::ref isrListener, Json::Value& jvResult)
{
uint256 uRandom;
if (theConfig.RUN_STANDALONE)
jvResult["stand_alone"] = theConfig.RUN_STANDALONE;
if (getConfig ().RUN_STANDALONE)
jvResult["stand_alone"] = getConfig ().RUN_STANDALONE;
if (theConfig.TESTNET)
jvResult["testnet"] = theConfig.TESTNET;
if (getConfig ().TESTNET)
jvResult["testnet"] = getConfig ().TESTNET;
RandomNumbers::getInstance ().fillBytes (uRandom.begin (), uRandom.size ());
jvResult["random"] = uRandom.ToString ();

View File

@@ -144,7 +144,7 @@ std::vector<RippleAddress> SerializedTransaction::getMentionedAccounts () const
uint256 SerializedTransaction::getSigningHash () const
{
return STObject::getSigningHash (theConfig.SIGN_TRANSACTION);
return STObject::getSigningHash (getConfig ().SIGN_TRANSACTION);
}
uint256 SerializedTransaction::getTransactionID () const

View File

@@ -209,7 +209,7 @@ public:
if (ptr)
{
mPingTimer.expires_from_now (boost::posix_time::seconds (theConfig.WEBSOCKET_PING_FREQ));
mPingTimer.expires_from_now (boost::posix_time::seconds (getConfig ().WEBSOCKET_PING_FREQ));
mPingTimer.async_wait (ptr->get_strand ().wrap (boost::bind (
&WSConnection<endpoint_type>::pingTimer, mConnection, mHandler, boost::asio::placeholders::error)));
}

View File

@@ -47,13 +47,13 @@ protected:
public:
WSServerHandler (boost::shared_ptr<boost::asio::ssl::context> spCtx, bool bPublic) : mCtx (spCtx), mPublic (bPublic)
{
if (theConfig.WEBSOCKET_SECURE != 0)
if (getConfig ().WEBSOCKET_SECURE != 0)
{
basio::SslContext::initializeFromFile (
*mCtx,
theConfig.WEBSOCKET_SSL_KEY,
theConfig.WEBSOCKET_SSL_CERT,
theConfig.WEBSOCKET_SSL_CHAIN);
getConfig ().WEBSOCKET_SSL_KEY,
getConfig ().WEBSOCKET_SSL_CERT,
getConfig ().WEBSOCKET_SSL_CHAIN);
}
}

View File

@@ -30,7 +30,7 @@ public:
if (keyValues ["cache_mb"].isEmpty ())
{
options.block_cache = hyperleveldb::NewLRUCache (theConfig.getSize (siHashNodeDBCache) * 1024 * 1024);
options.block_cache = hyperleveldb::NewLRUCache (getConfig ().getSize (siHashNodeDBCache) * 1024 * 1024);
}
else
{
@@ -39,7 +39,7 @@ public:
if (keyValues ["filter_bits"].isEmpty())
{
if (theConfig.NODE_SIZE >= 2)
if (getConfig ().NODE_SIZE >= 2)
options.filter_policy = hyperleveldb::NewBloomFilterPolicy (10);
}
else if (keyValues ["filter_bits"].getIntValue() != 0)

View File

@@ -30,7 +30,7 @@ public:
if (keyValues["cache_mb"].isEmpty())
{
options.block_cache = leveldb::NewLRUCache (theConfig.getSize (siHashNodeDBCache) * 1024 * 1024);
options.block_cache = leveldb::NewLRUCache (getConfig ().getSize (siHashNodeDBCache) * 1024 * 1024);
}
else
{
@@ -39,7 +39,7 @@ public:
if (keyValues["filter_bits"].isEmpty())
{
if (theConfig.NODE_SIZE >= 2)
if (getConfig ().NODE_SIZE >= 2)
options.filter_policy = leveldb::NewBloomFilterPolicy (10);
}
else if (keyValues["filter_bits"].getIntValue() != 0)

View File

@@ -42,7 +42,7 @@ public:
// VFALCO TODO Remove this dependency on theConfig
//
s << "PRAGMA cache_size=-" << String (theConfig.getSize(siHashNodeDBCache) * 1024);
s << "PRAGMA cache_size=-" << String (getConfig ().getSize(siHashNodeDBCache) * 1024);
m_db->getDB()->executeSQL (s.toStdString ().c_str ());
}

View File

@@ -277,7 +277,7 @@ bool PathRequest::doUpdate (RippleLineCache::ref cache, bool fast)
currIssuer.first, currIssuer.second, saDstAmount, valid);
CondLog (!valid, lsINFO, PathRequest) << "PF request not valid";
if (valid && pf.findPaths (theConfig.PATH_SEARCH_SIZE - (fast ? 0 : 1), 3, spsPaths))
if (valid && pf.findPaths (getConfig ().PATH_SEARCH_SIZE - (fast ? 0 : 1), 3, spsPaths))
{
LedgerEntrySet lesSandbox (cache->getLedger (), tapNONE);
std::vector<PathState::pointer> vpsExpanded;

View File

@@ -954,12 +954,12 @@ void PeerImp::recvHello (protocol::TMHello& packet)
#endif
if ((packet.has_testnet () && packet.testnet ()) != theConfig.TESTNET)
if ((packet.has_testnet () && packet.testnet ()) != getConfig ().TESTNET)
{
// Format: actual/requested.
WriteLog (lsINFO, Peer) << boost::str (boost::format ("Recv(Hello): Network mismatch: %d/%d")
% packet.testnet ()
% theConfig.TESTNET);
% getConfig ().TESTNET);
}
else if (packet.has_nettime () && ((packet.nettime () < minTime) || (packet.nettime () > maxTime)))
{
@@ -1289,7 +1289,7 @@ void PeerImp::recvPropose (const boost::shared_ptr<protocol::TMProposeSet>& pack
RippleAddress signerPublic = RippleAddress::createNodePublic (strCopy (set.nodepubkey ()));
if (signerPublic == theConfig.VALIDATION_PUB)
if (signerPublic == getConfig ().VALIDATION_PUB)
{
WriteLog (lsTRACE, Peer) << "Received our own proposal from peer " << mPeerId;
return;
@@ -2245,9 +2245,9 @@ void PeerImp::sendHello ()
h.set_nettime (getApp().getOPs ().getNetworkTimeNC ());
h.set_nodepublic (getApp().getLocalCredentials ().getNodePublic ().humanNodePublic ());
h.set_nodeproof (&vchSig[0], vchSig.size ());
h.set_ipv4port (theConfig.PEER_PORT);
h.set_nodeprivate (theConfig.PEER_PRIVATE);
h.set_testnet (theConfig.TESTNET);
h.set_ipv4port (getConfig ().PEER_PORT);
h.set_nodeprivate (getConfig ().PEER_PRIVATE);
h.set_testnet (getConfig ().TESTNET);
Ledger::pointer closedLedger = getApp().getLedgerMaster ().getClosedLedger ();

View File

@@ -135,7 +135,7 @@ void splitIpPort (const std::string& strIpPort, std::string& strIp, int& iPort)
void Peers::start ()
{
if (theConfig.RUN_STANDALONE)
if (getConfig ().RUN_STANDALONE)
return;
// Start running policy.
@@ -274,16 +274,16 @@ void Peers::policyLowWater ()
int iPort;
// Find an entry to connect to.
if (getPeerCount () > theConfig.PEER_CONNECT_LOW_WATER)
if (getPeerCount () > getConfig ().PEER_CONNECT_LOW_WATER)
{
// Above low water mark, don't need more connections.
WriteLog (lsTRACE, Peers) << "Pool: Low water: sufficient connections: " << mConnectedMap.size () << "/" << theConfig.PEER_CONNECT_LOW_WATER;
WriteLog (lsTRACE, Peers) << "Pool: Low water: sufficient connections: " << mConnectedMap.size () << "/" << getConfig ().PEER_CONNECT_LOW_WATER;
nothing ();
}
#if 0
else if (miConnectStarting == theConfig.PEER_START_MAX)
else if (miConnectStarting == getConfig ().PEER_START_MAX)
{
// Too many connections starting to start another.
nothing ();
@@ -625,7 +625,7 @@ bool Peers::peerScanSet (const std::string& strIp, int iPort)
if (db->getNull ("ScanNext"))
{
// Non-scanning connection terminated. Schedule for scanning.
int iInterval = theConfig.PEER_SCAN_INTERVAL_MIN;
int iInterval = getConfig ().PEER_SCAN_INTERVAL_MIN;
boost::posix_time::ptime tpNow = boost::posix_time::second_clock::universal_time ();
boost::posix_time::ptime tpNext = tpNow + boost::posix_time::seconds (iInterval);
@@ -766,10 +766,10 @@ void Peers::scanHandler (const boost::system::error_code& ecResult)
void Peers::makeConfigured ()
{
if (theConfig.RUN_STANDALONE)
if (getConfig ().RUN_STANDALONE)
return;
BOOST_FOREACH (const std::string & strPeer, theConfig.IPS)
BOOST_FOREACH (const std::string & strPeer, getConfig ().IPS)
{
std::string strIP;
int iPort;
@@ -782,7 +782,7 @@ void Peers::makeConfigured ()
// Scan ips as per db entries.
void Peers::scanRefresh ()
{
if (theConfig.RUN_STANDALONE)
if (getConfig ().RUN_STANDALONE)
{
nothing ();
}
@@ -838,7 +838,7 @@ void Peers::scanRefresh ()
(void) mScanTimer.cancel ();
iInterval = std::max (iInterval, theConfig.PEER_SCAN_INTERVAL_MIN);
iInterval = std::max (iInterval, getConfig ().PEER_SCAN_INTERVAL_MIN);
tpNext = tpNow + boost::posix_time::seconds (iInterval);

View File

@@ -428,49 +428,49 @@ public:
bool bLoaded = iDomains || iNodes;
// Always merge in the file specified in the config.
if (!theConfig.VALIDATORS_FILE.empty ())
if (!getConfig ().VALIDATORS_FILE.empty ())
{
WriteLog (lsINFO, UniqueNodeList) << "Bootstrapping UNL: loading from unl_default.";
bLoaded = nodeLoad (theConfig.VALIDATORS_FILE);
bLoaded = nodeLoad (getConfig ().VALIDATORS_FILE);
}
// If never loaded anything try the current directory.
if (!bLoaded && theConfig.VALIDATORS_FILE.empty ())
if (!bLoaded && getConfig ().VALIDATORS_FILE.empty ())
{
WriteLog (lsINFO, UniqueNodeList) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.")
% theConfig.VALIDATORS_BASE);
% getConfig ().VALIDATORS_BASE);
bLoaded = nodeLoad (theConfig.VALIDATORS_BASE);
bLoaded = nodeLoad (getConfig ().VALIDATORS_BASE);
}
// Always load from rippled.cfg
if (!theConfig.VALIDATORS.empty ())
if (!getConfig ().VALIDATORS.empty ())
{
RippleAddress naInvalid; // Don't want a referrer on added entries.
WriteLog (lsINFO, UniqueNodeList) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.")
% theConfig.CONFIG_FILE);
% getConfig ().CONFIG_FILE);
if (processValidators ("local", theConfig.CONFIG_FILE.string (), naInvalid, vsConfig, &theConfig.VALIDATORS))
if (processValidators ("local", getConfig ().CONFIG_FILE.string (), naInvalid, vsConfig, &getConfig ().VALIDATORS))
bLoaded = true;
}
if (!bLoaded)
{
WriteLog (lsINFO, UniqueNodeList) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.")
% theConfig.VALIDATORS_SITE);
% getConfig ().VALIDATORS_SITE);
nodeNetwork ();
}
if (!theConfig.IPS.empty ())
if (!getConfig ().IPS.empty ())
{
std::vector<std::string> vstrValues;
vstrValues.reserve (theConfig.IPS.size ());
vstrValues.reserve (getConfig ().IPS.size ());
BOOST_FOREACH (const std::string & strPeer, theConfig.IPS)
BOOST_FOREACH (const std::string & strPeer, getConfig ().IPS)
{
std::string strIP;
int iPort;
@@ -552,14 +552,14 @@ public:
void nodeNetwork ()
{
if (!theConfig.VALIDATORS_SITE.empty ())
if (!getConfig ().VALIDATORS_SITE.empty ())
{
HttpsClient::httpsGet (
true,
getApp().getIOService (),
theConfig.VALIDATORS_SITE,
getConfig ().VALIDATORS_SITE,
443,
theConfig.VALIDATORS_URI,
getConfig ().VALIDATORS_URI,
VALIDATORS_FILE_BYTES_MAX,
boost::posix_time::seconds (VALIDATORS_FETCH_SECONDS),
BIND_TYPE (&UniqueNodeListImp::validatorsResponse, this, P_1, P_2, P_3));
@@ -674,7 +674,7 @@ private:
void trustedLoad ()
{
boost::regex rNode ("\\`\\s*(\\S+)[\\s]*(.*)\\'");
BOOST_FOREACH (const std::string & c, theConfig.CLUSTER_NODES)
BOOST_FOREACH (const std::string & c, getConfig ().CLUSTER_NODES)
{
boost::smatch match;
@@ -1992,7 +1992,7 @@ private:
if (!err)
{
nodeProcess ("network", strResponse, theConfig.VALIDATORS_SITE);
nodeProcess ("network", strResponse, getConfig ().VALIDATORS_SITE);
}
else
{
@@ -2027,7 +2027,7 @@ private:
else
{
WriteLog (lsWARNING, UniqueNodeList) << boost::str (boost::format ("'%s' missing [" SECTION_VALIDATORS "].")
% theConfig.VALIDATORS_BASE);
% getConfig ().VALIDATORS_BASE);
}
}

View File

@@ -881,20 +881,20 @@ int commandLineRPC (const std::vector<std::string>& vCmd)
jvParams.append (jvRequest);
if (!theConfig.RPC_ADMIN_USER.empty ())
jvRequest["admin_user"] = theConfig.RPC_ADMIN_USER;
if (!getConfig ().RPC_ADMIN_USER.empty ())
jvRequest["admin_user"] = getConfig ().RPC_ADMIN_USER;
if (!theConfig.RPC_ADMIN_PASSWORD.empty ())
jvRequest["admin_password"] = theConfig.RPC_ADMIN_PASSWORD;
if (!getConfig ().RPC_ADMIN_PASSWORD.empty ())
jvRequest["admin_password"] = getConfig ().RPC_ADMIN_PASSWORD;
boost::asio::io_service isService;
callRPC (
isService,
theConfig.getRpcIP (),
theConfig.getRpcPort (),
theConfig.RPC_USER,
theConfig.RPC_PASSWORD,
getConfig ().getRpcIP (),
getConfig ().getRpcPort (),
getConfig ().RPC_USER,
getConfig ().RPC_PASSWORD,
"",
jvRequest.isMember ("method") // Allow parser to rewrite method.
? jvRequest["method"].asString () : vCmd[0],
@@ -1026,7 +1026,7 @@ void callRPC (
FUNCTION_TYPE<void (const Json::Value& jvInput)> callbackFuncP)
{
// Connect to localhost
if (!theConfig.QUIET)
if (!getConfig ().QUIET)
{
Log::out() << "Connecting to: " << strIp << ":" << iPort;
// Log::out() << "Username: " << strUsername << ":" << strPassword;

View File

@@ -9,21 +9,21 @@ SETUP_LOG (RPCDoor)
RPCDoor::RPCDoor (boost::asio::io_service& io_service, RPCServer::Handler& handler)
: m_rpcServerHandler (handler)
, mAcceptor (io_service,
boost::asio::ip::tcp::endpoint (boost::asio::ip::address::from_string (theConfig.getRpcIP ()), theConfig.getRpcPort ()))
boost::asio::ip::tcp::endpoint (boost::asio::ip::address::from_string (getConfig ().getRpcIP ()), getConfig ().getRpcPort ()))
, mDelayTimer (io_service)
, mSSLContext (boost::asio::ssl::context::sslv23)
{
WriteLog (lsINFO, RPCDoor) << "RPC port: " << theConfig.getRpcAddress().toRawUTF8() << " allow remote: " << theConfig.RPC_ALLOW_REMOTE;
WriteLog (lsINFO, RPCDoor) << "RPC port: " << getConfig ().getRpcAddress().toRawUTF8() << " allow remote: " << getConfig ().RPC_ALLOW_REMOTE;
if (theConfig.RPC_SECURE != 0)
if (getConfig ().RPC_SECURE != 0)
{
// VFALCO TODO This could be a method of theConfig
//
basio::SslContext::initializeFromFile (
mSSLContext,
theConfig.RPC_SSL_KEY,
theConfig.RPC_SSL_CERT,
theConfig.RPC_SSL_CHAIN);
getConfig ().RPC_SSL_KEY,
getConfig ().RPC_SSL_CERT,
getConfig ().RPC_SSL_CHAIN);
}
startListening ();
@@ -31,7 +31,7 @@ RPCDoor::RPCDoor (boost::asio::io_service& io_service, RPCServer::Handler& handl
RPCDoor::~RPCDoor ()
{
WriteLog (lsINFO, RPCDoor) << "RPC port: " << theConfig.getRpcAddress().toRawUTF8() << " allow remote: " << theConfig.RPC_ALLOW_REMOTE;
WriteLog (lsINFO, RPCDoor) << "RPC port: " << getConfig ().getRpcAddress().toRawUTF8() << " allow remote: " << getConfig ().RPC_ALLOW_REMOTE;
}
void RPCDoor::startListening ()
@@ -46,7 +46,7 @@ void RPCDoor::startListening ()
bool RPCDoor::isClientAllowed (const std::string& ip)
{
if (theConfig.RPC_ALLOW_REMOTE)
if (getConfig ().RPC_ALLOW_REMOTE)
return true;
// VFALCO TODO Represent ip addresses as a structure. Use isLoopback() member here

View File

@@ -14,20 +14,20 @@ int iAdminGet (const Json::Value& params, const std::string& strRemoteIp)
{
int iRole;
bool bPasswordSupplied = params.isMember ("admin_user") || params.isMember ("admin_password");
bool bPasswordRequired = !theConfig.RPC_ADMIN_USER.empty () || !theConfig.RPC_ADMIN_PASSWORD.empty ();
bool bPasswordRequired = !getConfig ().RPC_ADMIN_USER.empty () || !getConfig ().RPC_ADMIN_PASSWORD.empty ();
bool bPasswordWrong = bPasswordSupplied
? bPasswordRequired
// Supplied, required, and incorrect.
? theConfig.RPC_ADMIN_USER != (params.isMember ("admin_user") ? params["admin_user"].asString () : "")
|| theConfig.RPC_ADMIN_PASSWORD != (params.isMember ("admin_user") ? params["admin_password"].asString () : "")
? getConfig ().RPC_ADMIN_USER != (params.isMember ("admin_user") ? params["admin_user"].asString () : "")
|| getConfig ().RPC_ADMIN_PASSWORD != (params.isMember ("admin_user") ? params["admin_password"].asString () : "")
// Supplied and not required.
: true
: false;
// Meets IP restriction for admin.
bool bAdminIP = false;
BOOST_FOREACH (const std::string & strAllowIp, theConfig.RPC_ADMIN_ALLOW)
BOOST_FOREACH (const std::string & strAllowIp, getConfig ().RPC_ADMIN_ALLOW)
{
if (strAllowIp == strRemoteIp)
bAdminIP = true;
@@ -132,7 +132,7 @@ Json::Value RPCHandler::transactionSign (Json::Value params, bool bSubmit, bool
|| "TrustSet" == sType))
{
// feeReq = lSnapshot->scaleFeeLoad(,
txJSON["Fee"] = (int) theConfig.FEE_DEFAULT;
txJSON["Fee"] = (int) getConfig ().FEE_DEFAULT;
}
if ("Payment" == sType)
@@ -194,7 +194,7 @@ Json::Value RPCHandler::transactionSign (Json::Value params, bool bSubmit, bool
Pathfinder pf (cache, raSrcAddressID, dstAccountID,
saSendMax.getCurrency (), saSendMax.getIssuer (), saSend, bValid);
if (!bValid || !pf.findPaths (theConfig.PATH_SEARCH_SIZE, 3, spsPaths))
if (!bValid || !pf.findPaths (getConfig ().PATH_SEARCH_SIZE, 3, spsPaths))
{
WriteLog (lsDEBUG, RPCHandler) << "transactionSign: build_path: No paths found.";
@@ -213,6 +213,16 @@ Json::Value RPCHandler::transactionSign (Json::Value params, bool bSubmit, bool
}
}
if (!txJSON.isMember ("Fee")
&& (
"AccountSet" == txJSON["TransactionType"].asString ()
|| "OfferCreate" == txJSON["TransactionType"].asString ()
|| "OfferCancel" == txJSON["TransactionType"].asString ()
|| "TrustSet" == txJSON["TransactionType"].asString ()))
{
txJSON["Fee"] = (int) getConfig ().FEE_DEFAULT;
}
if (!txJSON.isMember ("Sequence"))
{
if (bOffline)
@@ -252,7 +262,7 @@ Json::Value RPCHandler::transactionSign (Json::Value params, bool bSubmit, bool
// Don't look at ledger entries to determine if the account exists. Don't want to leak to thin server that these accounts are
// related.
while (!bFound && iIndex != theConfig.ACCOUNT_PROBE_MAX)
while (!bFound && iIndex != getConfig ().ACCOUNT_PROBE_MAX)
{
naMasterAccountPublic.setAccountPublic (naMasterGenerator, iIndex);
@@ -473,7 +483,7 @@ Json::Value RPCHandler::authorize (Ledger::ref lrLedger,
// Don't look at ledger entries to determine if the account exists. Don't want to leak to thin server that these accounts are
// related.
while (!bFound && iIndex != theConfig.ACCOUNT_PROBE_MAX)
while (!bFound && iIndex != getConfig ().ACCOUNT_PROBE_MAX)
{
naMasterAccountPublic.setAccountPublic (naMasterGenerator, iIndex);
@@ -640,7 +650,7 @@ Json::Value RPCHandler::doAccountInfo (Json::Value params, LoadType* loadType, A
// XXX Might allow domain for manual connections.
Json::Value RPCHandler::doConnect (Json::Value params, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (theConfig.RUN_STANDALONE)
if (getConfig ().RUN_STANDALONE)
return "cannot connect in standalone mode";
if (!params.isMember ("ip"))
@@ -864,7 +874,7 @@ Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, Appli
STAmount saSrcBalanceA;
Json::Value jvObjA = authorize(uint256(0), naSeedA, naAccountA, naAccountPublicA, naAccountPrivateA,
saSrcBalanceA, theConfig.FEE_DEFAULT, asSrcA, naMasterGeneratorA);
saSrcBalanceA, getConfig ().FEE_DEFAULT, asSrcA, naMasterGeneratorA);
if (!jvObjA.empty())
return jvObjA;
@@ -873,7 +883,7 @@ Json::Value RPCHandler::doProfile (Json::Value params, LoadType* loadType, Appli
naAccountPublicA, naAccountPrivateA,
naAccountA, // naSourceAccount,
asSrcA->getSeq(), // uSeq
theConfig.FEE_DEFAULT,
getConfig ().FEE_DEFAULT,
0, // uSourceTag,
false, // bPassive
STAmount(uCurrencyOfferA, naAccountA.getAccountID(), 1), // saTakerPays
@@ -1538,7 +1548,7 @@ Json::Value RPCHandler::doRipplePathFind (Json::Value params, LoadType* loadType
bool bValid;
Pathfinder pf (cache, raSrc, raDst, uSrcCurrencyID, uSrcIssuerID, saDstAmount, bValid);
if (!bValid || !pf.findPaths (theConfig.PATH_SEARCH_SIZE, 3, spsComputed))
if (!bValid || !pf.findPaths (getConfig ().PATH_SEARCH_SIZE, 3, spsComputed))
{
WriteLog (lsWARNING, RPCHandler) << "ripple_path_find: No paths found.";
}
@@ -2143,25 +2153,25 @@ Json::Value RPCHandler::doValidationSeed (Json::Value params, LoadType* loadType
{
Log::out() << "Unset validation seed.";
theConfig.VALIDATION_SEED.clear ();
theConfig.VALIDATION_PUB.clear ();
theConfig.VALIDATION_PRIV.clear ();
getConfig ().VALIDATION_SEED.clear ();
getConfig ().VALIDATION_PUB.clear ();
getConfig ().VALIDATION_PRIV.clear ();
}
else if (!theConfig.VALIDATION_SEED.setSeedGeneric (params["secret"].asString ()))
else if (!getConfig ().VALIDATION_SEED.setSeedGeneric (params["secret"].asString ()))
{
theConfig.VALIDATION_PUB.clear ();
theConfig.VALIDATION_PRIV.clear ();
getConfig ().VALIDATION_PUB.clear ();
getConfig ().VALIDATION_PRIV.clear ();
return rpcError (rpcBAD_SEED);
}
else
{
theConfig.VALIDATION_PUB = RippleAddress::createNodePublic (theConfig.VALIDATION_SEED);
theConfig.VALIDATION_PRIV = RippleAddress::createNodePrivate (theConfig.VALIDATION_SEED);
getConfig ().VALIDATION_PUB = RippleAddress::createNodePublic (getConfig ().VALIDATION_SEED);
getConfig ().VALIDATION_PRIV = RippleAddress::createNodePrivate (getConfig ().VALIDATION_SEED);
obj["validation_public_key"] = theConfig.VALIDATION_PUB.humanNodePublic ();
obj["validation_seed"] = theConfig.VALIDATION_SEED.humanSeed ();
obj["validation_key"] = theConfig.VALIDATION_SEED.humanSeed1751 ();
obj["validation_public_key"] = getConfig ().VALIDATION_PUB.humanNodePublic ();
obj["validation_seed"] = getConfig ().VALIDATION_SEED.humanSeed ();
obj["validation_key"] = getConfig ().VALIDATION_SEED.humanSeed1751 ();
}
return obj;
@@ -2334,7 +2344,7 @@ Json::Value RPCHandler::doLogin (Json::Value params, LoadType* loadType, Applica
|| !params.isMember ("password"))
return rpcError (rpcINVALID_PARAMS);
if (params["username"].asString () == theConfig.RPC_USER && params["password"].asString () == theConfig.RPC_PASSWORD)
if (params["username"].asString () == getConfig ().RPC_USER && params["password"].asString () == getConfig ().RPC_PASSWORD)
{
//mRole=ADMIN;
return "logged in";
@@ -2559,7 +2569,7 @@ Json::Value RPCHandler::doUnlList (Json::Value, LoadType* loadType, Application:
// Populate the UNL from a local validators.txt file.
Json::Value RPCHandler::doUnlLoad (Json::Value, LoadType* loadType, Application::ScopedLockType& masterLockHolder)
{
if (theConfig.VALIDATORS_FILE.empty () || !getApp().getUNL ().nodeLoad (theConfig.VALIDATORS_FILE))
if (getConfig ().VALIDATORS_FILE.empty () || !getApp().getUNL ().nodeLoad (getConfig ().VALIDATORS_FILE))
{
return rpcError (rpcLOAD_FAILED);
}
@@ -2612,7 +2622,7 @@ Json::Value RPCHandler::doLedgerAccept (Json::Value, LoadType* loadType, Applica
{
Json::Value jvResult;
if (!theConfig.RUN_STANDALONE)
if (!getConfig ().RUN_STANDALONE)
{
jvResult["error"] = "notStandAlone";
}
@@ -3702,7 +3712,7 @@ Json::Value RPCHandler::doCommand (const Json::Value& params, int iRole, LoadTyp
return rpcError (rpcNO_NETWORK);
}
if (!theConfig.RUN_STANDALONE && (commandsA[i].iOptions & optCurrent) && (getApp().getLedgerMaster().getValidatedLedgerAge() > 120))
if (!getConfig ().RUN_STANDALONE && (commandsA[i].iOptions & optCurrent) && (getApp().getLedgerMaster().getValidatedLedgerAge() > 120))
{
return rpcError (rpcNO_CURRENT);
}

View File

@@ -105,7 +105,7 @@ std::string HTTPReply (int nStatus, const std::string& strMsg)
std::string access;
if (theConfig.RPC_ALLOW_REMOTE) access = "Access-Control-Allow-Origin: *\r\n";
if (getConfig ().RPC_ALLOW_REMOTE) access = "Access-Control-Allow-Origin: *\r\n";
else access = "";
return strprintf (
@@ -221,7 +221,7 @@ bool HTTPAuthorized (const std::map<std::string, std::string>& mapHeaders)
std::map<std::string, std::string>::const_iterator it = mapHeaders.find ("authorization");
if ((it == mapHeaders.end ()) || (it->second.substr (0, 6) != "Basic "))
return theConfig.RPC_USER.empty () && theConfig.RPC_PASSWORD.empty ();
return getConfig ().RPC_USER.empty () && getConfig ().RPC_PASSWORD.empty ();
std::string strUserPass64 = it->second.substr (6);
boost::trim (strUserPass64);
@@ -233,7 +233,7 @@ bool HTTPAuthorized (const std::map<std::string, std::string>& mapHeaders)
std::string strUser = strUserPass.substr (0, nColon);
std::string strPassword = strUserPass.substr (nColon + 1);
return (strUser == theConfig.RPC_USER) && (strPassword == theConfig.RPC_PASSWORD);
return (strUser == getConfig ().RPC_USER) && (strPassword == getConfig ().RPC_PASSWORD);
}
//

View File

@@ -54,7 +54,7 @@ void Transactor::calculateFee ()
uint64 Transactor::calculateBaseFee ()
{
return theConfig.FEE_DEFAULT;
return getConfig ().FEE_DEFAULT;
}
TER Transactor::payFee ()

View File

@@ -18,7 +18,11 @@
// VFALCO TODO Convert this to a SharedSingleton to prevent exit leaks
//
Config theConfig;
Config& getConfig ()
{
static Config config;
return config;
}
Config::Config ()
: m_rpcPort (5001)
@@ -315,13 +319,13 @@ void Config::load ()
//
// VFALCO BEGIN CLEAN
//
theConfig.nodeDatabase = parseKeyValueSection (
getConfig ().nodeDatabase = parseKeyValueSection (
secConfig, ConfigSection::nodeDatabase ());
theConfig.ephemeralNodeDatabase = parseKeyValueSection (
getConfig ().ephemeralNodeDatabase = parseKeyValueSection (
secConfig, ConfigSection::tempNodeDatabase ());
theConfig.importNodeDatabase = parseKeyValueSection (
getConfig ().importNodeDatabase = parseKeyValueSection (
secConfig, ConfigSection::importNodeDatabase ());
//
// VFALCO END CLEAN

View File

@@ -321,7 +321,7 @@ public:
void load ();
};
extern Config theConfig;
extern Config& getConfig ();
#endif

View File

@@ -10,20 +10,20 @@
SETUP_LOG (HttpsClient)
// VFALCO NOTE Why use theConfig.SSL_CONTEXT instead of just passing it?
// VFALCO NOTE Why use getConfig ().SSL_CONTEXT instead of just passing it?
// TODO Remove all theConfig deps from this file
//
HttpsClient::HttpsClient (boost::asio::io_service& io_service,
const unsigned short port,
std::size_t responseMax)
: mSocket (io_service, theConfig.SSL_CONTEXT)
: mSocket (io_service, getConfig ().SSL_CONTEXT)
, mResolver (io_service)
, mHeader (maxClientHeaderBytes)
, mPort (port)
, mResponseMax (responseMax)
, mDeadline (io_service)
{
if (!theConfig.SSL_VERIFY)
if (!getConfig ().SSL_VERIFY)
mSocket.SSLSocket ().set_verify_mode (boost::asio::ssl::verify_none);
}
@@ -201,7 +201,7 @@ void HttpsClient::handleConnect (const boost::system::error_code& ecResult)
{
WriteLog (lsTRACE, HttpsClient) << "Connected.";
if (theConfig.SSL_VERIFY)
if (getConfig ().SSL_VERIFY)
{
mShutdown = mSocket.verify (mDeqSites[0]);
@@ -469,9 +469,9 @@ void HttpsClient::sendSMS (boost::asio::io_service& io_service, const std::strin
int iPort;
std::string strPath;
if (theConfig.SMS_URL == "" || !parseUrl (theConfig.SMS_URL, strScheme, strDomain, iPort, strPath))
if (getConfig ().SMS_URL == "" || !parseUrl (getConfig ().SMS_URL, strScheme, strDomain, iPort, strPath))
{
WriteLog (lsWARNING, HttpsClient) << "SMSRequest: Bad URL:" << theConfig.SMS_URL;
WriteLog (lsWARNING, HttpsClient) << "SMSRequest: Bad URL:" << getConfig ().SMS_URL;
}
else
{
@@ -481,10 +481,10 @@ void HttpsClient::sendSMS (boost::asio::io_service& io_service, const std::strin
std::string strURI =
boost::str (boost::format ("%s?from=%s&to=%s&api_key=%s&api_secret=%s&text=%s")
% (strPath.empty () ? "/" : strPath)
% theConfig.SMS_FROM
% theConfig.SMS_TO
% theConfig.SMS_KEY
% theConfig.SMS_SECRET
% getConfig ().SMS_FROM
% getConfig ().SMS_TO
% getConfig ().SMS_KEY
% getConfig ().SMS_SECRET
% urlEncode (strText));
// WriteLog (lsINFO) << "SMS: Request:" << strURI;