mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Cleanups:
* Remove obsolete config variables * Reduce coupling * Use C++11 ownership containers * Use auto when it makes sense * Detect edge-case in unit tests * Reduce the number of LedgerEntrySet public members
This commit is contained in:
@@ -115,7 +115,7 @@ composed_quality (Quality const& lhs, Quality const& rhs)
|
||||
std::uint64_t const stored_exponent (rate.getExponent () + 100);
|
||||
std::uint64_t const stored_mantissa (rate.getMantissa ());
|
||||
|
||||
assert ((stored_exponent >= 0) && (stored_exponent <= 255));
|
||||
assert ((stored_exponent > 0) && (stored_exponent <= 255));
|
||||
|
||||
return Quality ((stored_exponent << (64 - 8)) | stored_mantissa);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class InboundLedgersImp
|
||||
@@ -397,10 +399,11 @@ InboundLedgers::~InboundLedgers()
|
||||
{
|
||||
}
|
||||
|
||||
InboundLedgers* InboundLedgers::New (clock_type& clock, beast::Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector)
|
||||
std::unique_ptr<InboundLedgers>
|
||||
make_InboundLedgers (InboundLedgers::clock_type& clock, beast::Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector)
|
||||
{
|
||||
return new InboundLedgersImp (clock, parent, collector);
|
||||
return std::make_unique<InboundLedgersImp> (clock, parent, collector);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef RIPPLE_INBOUNDLEDGERS_H
|
||||
#define RIPPLE_INBOUNDLEDGERS_H
|
||||
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
/** Manages the lifetime of inbound ledgers.
|
||||
@@ -33,13 +35,6 @@ public:
|
||||
|
||||
virtual ~InboundLedgers() = 0;
|
||||
|
||||
// VFALCO TODO Make this a free function outside the class:
|
||||
// std::unique_ptr <InboundLedger> make_InboundLedgers (...)
|
||||
//
|
||||
static InboundLedgers* New (clock_type& clock, beast::Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector);
|
||||
|
||||
|
||||
// VFALCO TODO Should this be called findOrAdd ?
|
||||
//
|
||||
virtual InboundLedger::pointer findCreate (uint256 const& hash,
|
||||
@@ -79,6 +74,11 @@ public:
|
||||
virtual void onStop() = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<InboundLedgers>
|
||||
make_InboundLedgers (InboundLedgers::clock_type& clock, beast::Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector);
|
||||
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -686,14 +686,14 @@ bool Ledger::saveValidatedLedger (bool current)
|
||||
}
|
||||
|
||||
{
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
getApp().getLedgerDB ()->getDB ()->executeSQL (
|
||||
auto sl (getApp().getLedgerDB ().lock ());
|
||||
getApp().getLedgerDB ().getDB ()->executeSQL (
|
||||
boost::str (deleteLedger % mLedgerSeq));
|
||||
}
|
||||
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
auto dbLock (getApp().getTxnDB ()->lock ());
|
||||
auto db = getApp().getTxnDB ().getDB ();
|
||||
auto dbLock (getApp().getTxnDB ().lock ());
|
||||
db->executeSQL ("BEGIN TRANSACTION;");
|
||||
|
||||
db->executeSQL (boost::str (deleteTrans1 % getLedgerSeq ()));
|
||||
@@ -766,10 +766,10 @@ bool Ledger::saveValidatedLedger (bool current)
|
||||
}
|
||||
|
||||
{
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
auto sl (getApp().getLedgerDB ().lock ());
|
||||
|
||||
// TODO(tom): ARG!
|
||||
getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (addLedger %
|
||||
getApp().getLedgerDB ().getDB ()->executeSQL (boost::str (addLedger %
|
||||
to_string (getHash ()) % mLedgerSeq % to_string (mParentHash) %
|
||||
beast::lexicalCastThrow <std::string> (mTotCoins) % mCloseTime %
|
||||
mParentCloseTime % mCloseResolution % mCloseFlags %
|
||||
@@ -791,8 +791,8 @@ Ledger::pointer Ledger::loadByIndex (std::uint32_t ledgerIndex)
|
||||
{
|
||||
Ledger::pointer ledger;
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
auto db = getApp().getLedgerDB ().getDB ();
|
||||
auto sl (getApp().getLedgerDB ().lock ());
|
||||
|
||||
SqliteStatement pSt (
|
||||
db->getSqliteDB (), "SELECT "
|
||||
@@ -817,8 +817,8 @@ Ledger::pointer Ledger::loadByHash (uint256 const& ledgerHash)
|
||||
{
|
||||
Ledger::pointer ledger;
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
auto db = getApp().getLedgerDB ().getDB ();
|
||||
auto sl (getApp().getLedgerDB ().lock ());
|
||||
|
||||
SqliteStatement pSt (
|
||||
db->getSqliteDB (), "SELECT "
|
||||
@@ -874,8 +874,8 @@ Ledger::pointer Ledger::getSQL (std::string const& sql)
|
||||
std::string hash;
|
||||
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
auto db = getApp().getLedgerDB ().getDB ();
|
||||
auto sl (getApp().getLedgerDB ().lock ());
|
||||
|
||||
if (!db->executeSQL (sql) || !db->startIterRows ())
|
||||
return Ledger::pointer ();
|
||||
@@ -999,8 +999,8 @@ uint256 Ledger::getHashByIndex (std::uint32_t ledgerIndex)
|
||||
|
||||
std::string hash;
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
auto db = getApp().getLedgerDB ().getDB ();
|
||||
auto sl (getApp().getLedgerDB ().lock ());
|
||||
|
||||
if (!db->executeSQL (sql) || !db->startIterRows ())
|
||||
return ret;
|
||||
@@ -1018,10 +1018,10 @@ bool Ledger::getHashesByIndex (
|
||||
{
|
||||
#ifndef NO_SQLITE3_PREPARE
|
||||
|
||||
DatabaseCon* con = getApp().getLedgerDB ();
|
||||
auto sl (con->lock ());
|
||||
auto& con = getApp().getLedgerDB ();
|
||||
auto sl (con.lock ());
|
||||
|
||||
SqliteStatement pSt (con->getDB ()->getSqliteDB (),
|
||||
SqliteStatement pSt (con.getDB ()->getSqliteDB (),
|
||||
"SELECT LedgerHash,PrevHash FROM Ledgers "
|
||||
"INDEXED BY SeqLedger Where LedgerSeq = ?;");
|
||||
|
||||
@@ -1056,8 +1056,8 @@ bool Ledger::getHashesByIndex (
|
||||
|
||||
std::string hash, prevHash;
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
auto db = getApp().getLedgerDB ().getDB ();
|
||||
auto sl (getApp().getLedgerDB ().lock ());
|
||||
|
||||
if (!db->executeSQL (sql) || !db->startIterRows ())
|
||||
return false;
|
||||
@@ -1090,10 +1090,10 @@ Ledger::getHashesByIndex (std::uint32_t minSeq, std::uint32_t maxSeq)
|
||||
sql.append (beast::lexicalCastThrow <std::string> (maxSeq));
|
||||
sql.append (";");
|
||||
|
||||
DatabaseCon* con = getApp().getLedgerDB ();
|
||||
auto sl (con->lock ());
|
||||
auto& con = getApp().getLedgerDB ();
|
||||
auto sl (con.lock ());
|
||||
|
||||
SqliteStatement pSt (con->getDB ()->getSqliteDB (), sql);
|
||||
SqliteStatement pSt (con.getDB ()->getSqliteDB (), sql);
|
||||
|
||||
while (pSt.isRow (pSt.step ()))
|
||||
{
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
/*
|
||||
@@ -440,11 +442,10 @@ LedgerCleaner::~LedgerCleaner ()
|
||||
{
|
||||
}
|
||||
|
||||
LedgerCleaner* LedgerCleaner::New (
|
||||
Stoppable& parent,
|
||||
beast::Journal journal)
|
||||
std::unique_ptr<LedgerCleaner>
|
||||
make_LedgerCleaner (beast::Stoppable& parent, beast::Journal journal)
|
||||
{
|
||||
return new LedgerCleanerImp (parent, journal);
|
||||
return std::make_unique <LedgerCleanerImp> (parent, journal);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef RIPPLE_LEDGERCLEANER_H_INCLUDED
|
||||
#define RIPPLE_LEDGERCLEANER_H_INCLUDED
|
||||
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
/** Check the ledger/transaction databases to make sure they have continuity */
|
||||
@@ -31,13 +33,6 @@ protected:
|
||||
explicit LedgerCleaner (Stoppable& parent);
|
||||
|
||||
public:
|
||||
/** Create a new object.
|
||||
The caller receives ownership and must delete the object when done.
|
||||
*/
|
||||
static LedgerCleaner* New (
|
||||
Stoppable& parent,
|
||||
beast::Journal journal);
|
||||
|
||||
/** Destroy the object. */
|
||||
virtual ~LedgerCleaner () = 0;
|
||||
|
||||
@@ -54,6 +49,9 @@ public:
|
||||
virtual void doClean (Json::Value const& parameters) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<LedgerCleaner> make_LedgerCleaner (beast::Stoppable& parent,
|
||||
beast::Journal journal);
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -99,17 +99,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// set functions
|
||||
void setImmutable ()
|
||||
{
|
||||
mImmutable = true;
|
||||
}
|
||||
|
||||
bool isImmutable () const
|
||||
{
|
||||
return mImmutable;
|
||||
}
|
||||
|
||||
// Make a duplicate of this set.
|
||||
LedgerEntrySet duplicate () const;
|
||||
|
||||
@@ -259,17 +248,25 @@ public:
|
||||
typedef std::map<uint256, LedgerEntrySetEntry>::iterator iterator;
|
||||
typedef std::map<uint256, LedgerEntrySetEntry>::const_iterator const_iterator;
|
||||
|
||||
bool isEmpty () const
|
||||
bool empty () const
|
||||
{
|
||||
return mEntries.empty ();
|
||||
}
|
||||
const_iterator cbegin () const
|
||||
{
|
||||
return mEntries.cbegin ();
|
||||
}
|
||||
const_iterator cend () const
|
||||
{
|
||||
return mEntries.cend ();
|
||||
}
|
||||
const_iterator begin () const
|
||||
{
|
||||
return mEntries.begin ();
|
||||
return mEntries.cbegin ();
|
||||
}
|
||||
const_iterator end () const
|
||||
{
|
||||
return mEntries.end ();
|
||||
return mEntries.cend ();
|
||||
}
|
||||
iterator begin ()
|
||||
{
|
||||
|
||||
@@ -85,7 +85,8 @@ public:
|
||||
, m_journal (journal)
|
||||
, mLedgerHistory (collector)
|
||||
, mHeldTransactions (uint256 ())
|
||||
, mLedgerCleaner (LedgerCleaner::New(*this, deprecatedLogs().journal("LedgerCleaner")))
|
||||
, mLedgerCleaner (make_LedgerCleaner (
|
||||
*this, deprecatedLogs().journal("LedgerCleaner")))
|
||||
, mMinValidations (0)
|
||||
, mLastValidateSeq (0)
|
||||
, mAdvanceThread (false)
|
||||
|
||||
@@ -55,7 +55,7 @@ uint256 LedgerProposal::getSigningHash () const
|
||||
{
|
||||
Serializer s ((32 + 32 + 32 + 256 + 256) / 8);
|
||||
|
||||
s.add32 (getConfig ().SIGN_PROPOSAL);
|
||||
s.add32 (HashPrefix::proposal);
|
||||
s.add32 (mProposeSeq);
|
||||
s.add32 (mCloseTime);
|
||||
s.add256 (mPreviousLedger);
|
||||
|
||||
@@ -69,7 +69,7 @@ void SerializedValidation::sign (uint256& signingHash, RippleAddress const& raPr
|
||||
|
||||
uint256 SerializedValidation::getSigningHash () const
|
||||
{
|
||||
return STObject::getSigningHash (getConfig ().SIGN_VALIDATION);
|
||||
return STObject::getSigningHash (HashPrefix::validation);
|
||||
}
|
||||
|
||||
uint256 SerializedValidation::getLedgerHash () const
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace ripple {
|
||||
// VFALCO TODO Clean this global up
|
||||
static bool volatile doShutdown = false;
|
||||
|
||||
// 204/256 about 80%
|
||||
static int const MAJORITY_FRACTION (204);
|
||||
|
||||
// This hack lets the s_instance variable remain set during
|
||||
@@ -292,24 +293,28 @@ public:
|
||||
// VFALCO NOTE must come before NetworkOPs to prevent a crash due
|
||||
// to dependencies in the destructor.
|
||||
//
|
||||
, m_inboundLedgers (InboundLedgers::New (get_seconds_clock (), *m_jobQueue,
|
||||
m_collectorManager->collector ()))
|
||||
, m_inboundLedgers (make_InboundLedgers (get_seconds_clock (),
|
||||
*m_jobQueue, m_collectorManager->collector ()))
|
||||
|
||||
// VFALCO NOTE Does NetworkOPs depend on LedgerMaster?
|
||||
, m_networkOPs (NetworkOPs::New (get_seconds_clock (), *m_ledgerMaster,
|
||||
*m_jobQueue, m_logs.journal("NetworkOPs")))
|
||||
, m_networkOPs (make_NetworkOPs (get_seconds_clock (),
|
||||
getConfig ().RUN_STANDALONE, getConfig ().NETWORK_QUORUM,
|
||||
*m_jobQueue, *m_ledgerMaster, *m_jobQueue,
|
||||
m_logs.journal("NetworkOPs")))
|
||||
|
||||
// VFALCO NOTE LocalCredentials starts the deprecated UNL service
|
||||
, m_deprecatedUNL (UniqueNodeList::New (*m_jobQueue))
|
||||
, m_deprecatedUNL (make_UniqueNodeList (*m_jobQueue))
|
||||
|
||||
, m_rpcHTTPServer (make_RPCHTTPServer (*m_networkOPs,
|
||||
m_logs.journal("HTTPServer"), *m_jobQueue, *m_networkOPs, *m_resourceManager))
|
||||
m_logs.journal("HTTPServer"), *m_jobQueue, *m_networkOPs,
|
||||
*m_resourceManager))
|
||||
|
||||
, m_rpcServerHandler (*m_networkOPs, *m_resourceManager) // passive object, not a Service
|
||||
// passive object, not a Service
|
||||
, m_rpcServerHandler (*m_networkOPs, *m_resourceManager)
|
||||
|
||||
, m_nodeStore (m_nodeStoreManager->make_Database ("NodeStore.main", m_nodeStoreScheduler,
|
||||
m_logs.journal("NodeObject"), 4, // four read threads for now
|
||||
getConfig ().nodeDatabase, getConfig ().ephemeralNodeDatabase))
|
||||
, m_nodeStore (m_nodeStoreManager->make_Database ("NodeStore.main",
|
||||
m_nodeStoreScheduler, m_logs.journal("NodeObject"),
|
||||
4, // four read threads for now
|
||||
getConfig ().nodeDatabase, getConfig ().ephemeralNodeDatabase))
|
||||
|
||||
, m_sntpClient (SNTPClient::New (*this))
|
||||
|
||||
@@ -320,16 +325,16 @@ public:
|
||||
getConfig ().getModuleDatabasePath (),
|
||||
m_logs.journal("Validators"))))
|
||||
|
||||
, m_amendmentTable (make_AmendmentTable (weeks(2), MAJORITY_FRACTION, // 204/256 about 80%
|
||||
, m_amendmentTable (make_AmendmentTable (weeks(2), MAJORITY_FRACTION,
|
||||
m_logs.journal("AmendmentTable")))
|
||||
|
||||
, mFeeTrack (LoadFeeTrack::New (m_logs.journal("LoadManager")))
|
||||
|
||||
, mHashRouter (IHashRouter::New (IHashRouter::getDefaultHoldTime ()))
|
||||
|
||||
, mValidations (Validations::New ())
|
||||
, mValidations (make_Validations ())
|
||||
|
||||
, mProofOfWorkFactory (ProofOfWorkFactory::New ())
|
||||
, mProofOfWorkFactory (make_ProofOfWorkFactory ())
|
||||
|
||||
, m_loadManager (LoadManager::New (*this, m_logs.journal("LoadManager")))
|
||||
|
||||
@@ -533,21 +538,25 @@ public:
|
||||
return m_sntpClient->getOffset (offset);
|
||||
}
|
||||
|
||||
DatabaseCon* getRpcDB ()
|
||||
DatabaseCon& getRpcDB ()
|
||||
{
|
||||
return mRpcDB.get();
|
||||
assert (mRpcDB.get() != nullptr);
|
||||
return *mRpcDB;
|
||||
}
|
||||
DatabaseCon* getTxnDB ()
|
||||
DatabaseCon& getTxnDB ()
|
||||
{
|
||||
return mTxnDB.get();
|
||||
assert (mTxnDB.get() != nullptr);
|
||||
return *mTxnDB;
|
||||
}
|
||||
DatabaseCon* getLedgerDB ()
|
||||
DatabaseCon& getLedgerDB ()
|
||||
{
|
||||
return mLedgerDB.get();
|
||||
assert (mLedgerDB.get() != nullptr);
|
||||
return *mLedgerDB;
|
||||
}
|
||||
DatabaseCon* getWalletDB ()
|
||||
DatabaseCon& getWalletDB ()
|
||||
{
|
||||
return mWalletDB.get();
|
||||
assert (mWalletDB.get() != nullptr);
|
||||
return *mWalletDB;
|
||||
}
|
||||
|
||||
bool isShutdown ()
|
||||
@@ -556,33 +565,23 @@ public:
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
static DatabaseCon* openDatabaseCon (const char* fileName,
|
||||
const char* dbInit[],
|
||||
int dbCount)
|
||||
bool initSqliteDbs ()
|
||||
{
|
||||
return new DatabaseCon (fileName, dbInit, dbCount);
|
||||
}
|
||||
assert (mRpcDB.get () == nullptr);
|
||||
assert (mTxnDB.get () == nullptr);
|
||||
assert (mLedgerDB.get () == nullptr);
|
||||
assert (mWalletDB.get () == nullptr);
|
||||
|
||||
void initSqliteDb (int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: mRpcDB.reset (openDatabaseCon ("rpc.db", RpcDBInit, RpcDBCount)); break;
|
||||
case 1: mTxnDB.reset (openDatabaseCon ("transaction.db", TxnDBInit, TxnDBCount)); break;
|
||||
case 2: mLedgerDB.reset (openDatabaseCon ("ledger.db", LedgerDBInit, LedgerDBCount)); break;
|
||||
case 3: mWalletDB.reset (openDatabaseCon ("wallet.db", WalletDBInit, WalletDBCount)); break;
|
||||
};
|
||||
}
|
||||
mRpcDB = std::make_unique <DatabaseCon> ("rpc.db", RpcDBInit, RpcDBCount);
|
||||
mTxnDB = std::make_unique <DatabaseCon> ("transaction.db", TxnDBInit, TxnDBCount);
|
||||
mLedgerDB = std::make_unique <DatabaseCon> ("ledger.db", LedgerDBInit, LedgerDBCount);
|
||||
mWalletDB = std::make_unique <DatabaseCon> ("wallet.db", WalletDBInit, WalletDBCount);
|
||||
|
||||
void initSqliteDbs ()
|
||||
{
|
||||
// VFALCO NOTE DBs are no longer initialized in parallel, since we
|
||||
// dont want unowned threads and because ParallelFor
|
||||
// is broken.
|
||||
//
|
||||
for (int i = 0; i < 4; ++i)
|
||||
initSqliteDb (i);
|
||||
return
|
||||
mRpcDB.get() != nullptr &&
|
||||
mTxnDB.get () != nullptr &&
|
||||
mLedgerDB.get () != nullptr &&
|
||||
mWalletDB.get () != nullptr;
|
||||
}
|
||||
|
||||
#ifdef SIGINT
|
||||
@@ -634,11 +633,15 @@ public:
|
||||
if (!getConfig ().RUN_STANDALONE)
|
||||
m_sntpClient->init (getConfig ().SNTP_SERVERS);
|
||||
|
||||
initSqliteDbs ();
|
||||
if (!initSqliteDbs ())
|
||||
{
|
||||
m_journal.fatal << "Can not create database connections!";
|
||||
exit (3);
|
||||
}
|
||||
|
||||
getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
||||
getApp().getLedgerDB ().getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
||||
(getConfig ().getSize (siLgrDBCache) * 1024)));
|
||||
getApp().getTxnDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
||||
getApp().getTxnDB ().getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
||||
(getConfig ().getSize (siTxnDBCache) * 1024)));
|
||||
|
||||
mTxnDB->getDB ()->setupCheckpointing (m_jobQueue.get());
|
||||
@@ -1403,7 +1406,7 @@ bool serverOkay (std::string& reason)
|
||||
|
||||
//VFALCO TODO clean this up since it is just a file holding a single member function definition
|
||||
|
||||
static std::vector<std::string> getSchema (DatabaseCon* dbc, std::string const& dbName)
|
||||
static std::vector<std::string> getSchema (DatabaseCon& dbc, std::string const& dbName)
|
||||
{
|
||||
std::vector<std::string> schema;
|
||||
|
||||
@@ -1411,16 +1414,16 @@ static std::vector<std::string> getSchema (DatabaseCon* dbc, std::string const&
|
||||
sql += dbName;
|
||||
sql += "';";
|
||||
|
||||
SQL_FOREACH (dbc->getDB (), sql)
|
||||
SQL_FOREACH (dbc.getDB (), sql)
|
||||
{
|
||||
dbc->getDB ()->getStr ("sql", sql);
|
||||
dbc.getDB ()->getStr ("sql", sql);
|
||||
schema.push_back (sql);
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
static bool schemaHas (DatabaseCon* dbc, std::string const& dbName, int line, std::string const& content)
|
||||
static bool schemaHas (DatabaseCon& dbc, std::string const& dbName, int line, std::string const& content)
|
||||
{
|
||||
std::vector<std::string> schema = getSchema (dbc, dbName);
|
||||
|
||||
@@ -1440,7 +1443,7 @@ static void addTxnSeqField ()
|
||||
|
||||
WriteLog (lsWARNING, Application) << "Transaction sequence field is missing";
|
||||
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
auto db = getApp().getTxnDB ().getDB ();
|
||||
|
||||
std::vector< std::pair<uint256, int> > txIDs;
|
||||
txIDs.reserve (300000);
|
||||
|
||||
@@ -115,9 +115,9 @@ public:
|
||||
virtual Resource::Manager& getResourceManager () = 0;
|
||||
virtual PathRequests& getPathRequests () = 0;
|
||||
|
||||
virtual DatabaseCon* getRpcDB () = 0;
|
||||
virtual DatabaseCon* getTxnDB () = 0;
|
||||
virtual DatabaseCon* getLedgerDB () = 0;
|
||||
virtual DatabaseCon& getRpcDB () = 0;
|
||||
virtual DatabaseCon& getTxnDB () = 0;
|
||||
virtual DatabaseCon& getLedgerDB () = 0;
|
||||
|
||||
virtual std::chrono::milliseconds getIOLatency () = 0;
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
// VFALCO TODO Rename, document this
|
||||
// NOTE This will be replaced by class Validators
|
||||
//
|
||||
virtual DatabaseCon* getWalletDB () = 0;
|
||||
virtual DatabaseCon& getWalletDB () = 0;
|
||||
|
||||
virtual bool getSystemTimeOffset (int& offset) = 0;
|
||||
virtual bool isShutdown () = 0;
|
||||
|
||||
@@ -47,8 +47,8 @@ void LocalCredentials::start ()
|
||||
// Retrieve network identity.
|
||||
bool LocalCredentials::nodeIdentityLoad ()
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
bool bSuccess = false;
|
||||
|
||||
if (db->executeSQL ("SELECT * FROM NodeIdentity;") && db->startIterRows ())
|
||||
@@ -88,25 +88,16 @@ bool LocalCredentials::nodeIdentityCreate ()
|
||||
RippleAddress naNodePrivate = RippleAddress::createNodePrivate (naSeed);
|
||||
|
||||
// Make new key.
|
||||
#ifdef CREATE_NEW_DH_PARAMS
|
||||
std::string strDh512 = DH_der_gen (512);
|
||||
|
||||
#else
|
||||
std::string strDh512 (RippleSSLContext::getRawDHParams (512));
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
std::string strDh1024 = strDh512; // For testing and most cases 512 is fine.
|
||||
#else
|
||||
std::string strDh1024 = DH_der_gen (1024);
|
||||
#endif
|
||||
std::string strDh1024 = strDh512;
|
||||
|
||||
//
|
||||
// Store the node information
|
||||
//
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
db->executeSQL (str (boost::format ("INSERT INTO NodeIdentity (PublicKey,PrivateKey,Dh512,Dh1024) VALUES ('%s','%s',%s,%s);")
|
||||
% naNodePublic.humanNodePublic ()
|
||||
% naNodePrivate.humanNodePrivate ()
|
||||
@@ -122,9 +113,9 @@ bool LocalCredentials::nodeIdentityCreate ()
|
||||
|
||||
bool LocalCredentials::dataDelete (std::string const& strKey)
|
||||
{
|
||||
Database* db = getApp().getRpcDB ()->getDB ();
|
||||
auto db = getApp().getRpcDB ().getDB ();
|
||||
|
||||
auto sl (getApp().getRpcDB ()->lock ());
|
||||
auto sl (getApp().getRpcDB ().lock ());
|
||||
|
||||
return db->executeSQL (str (boost::format ("DELETE FROM RPCData WHERE Key=%s;")
|
||||
% sqlEscape (strKey)));
|
||||
@@ -132,9 +123,9 @@ bool LocalCredentials::dataDelete (std::string const& strKey)
|
||||
|
||||
bool LocalCredentials::dataFetch (std::string const& strKey, std::string& strValue)
|
||||
{
|
||||
Database* db = getApp().getRpcDB ()->getDB ();
|
||||
auto db = getApp().getRpcDB ().getDB ();
|
||||
|
||||
auto sl (getApp().getRpcDB ()->lock ());
|
||||
auto sl (getApp().getRpcDB ().lock ());
|
||||
|
||||
bool bSuccess = false;
|
||||
|
||||
@@ -154,9 +145,9 @@ bool LocalCredentials::dataFetch (std::string const& strKey, std::string& strVal
|
||||
|
||||
bool LocalCredentials::dataStore (std::string const& strKey, std::string const& strValue)
|
||||
{
|
||||
Database* db = getApp().getRpcDB ()->getDB ();
|
||||
auto db = getApp().getRpcDB ().getDB ();
|
||||
|
||||
auto sl (getApp().getRpcDB ()->lock ());
|
||||
auto sl (getApp().getRpcDB ().lock ());
|
||||
|
||||
return (db->executeSQL (str (boost::format ("REPLACE INTO RPCData (Key, Value) VALUES (%s,%s);")
|
||||
% sqlEscape (strKey)
|
||||
|
||||
@@ -117,8 +117,8 @@ AmendmentTableImpl::getCreate (uint256 const& amendmentHash, bool create)
|
||||
query.append (to_string (amendmentHash));
|
||||
query.append ("';");
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
if (db->executeSQL (query) && db->startIterRows ())
|
||||
{
|
||||
@@ -373,8 +373,8 @@ AmendmentTableImpl::reportValidations (const AmendmentSet& set)
|
||||
|
||||
if (!changedAmendments.empty())
|
||||
{
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
db->executeSQL ("BEGIN TRANSACTION;");
|
||||
for (auto const& hash : changedAmendments)
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <ripple/common/jsonrpc_fields.h>
|
||||
#include <beast/module/core/thread/DeadlineTimer.h>
|
||||
#include <beast/module/core/system/SystemStats.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
#include <tuple>
|
||||
|
||||
namespace ripple {
|
||||
@@ -42,8 +43,10 @@ public:
|
||||
public:
|
||||
// VFALCO TODO Make LedgerMaster a SharedPtr or a reference.
|
||||
//
|
||||
NetworkOPsImp (clock_type& clock, LedgerMaster& ledgerMaster,
|
||||
Stoppable& parent, beast::Journal journal)
|
||||
NetworkOPsImp (
|
||||
clock_type& clock, bool standalone, std::size_t network_quorum,
|
||||
JobQueue& job_queue, LedgerMaster& ledgerMaster, Stoppable& parent,
|
||||
beast::Journal journal)
|
||||
: NetworkOPs (parent)
|
||||
, m_clock (clock)
|
||||
, m_journal (journal)
|
||||
@@ -68,6 +71,9 @@ public:
|
||||
, mFetchSeq (0)
|
||||
, mLastLoadBase (256)
|
||||
, mLastLoadFactor (256)
|
||||
, m_job_queue (job_queue)
|
||||
, m_standalone (standalone)
|
||||
, m_network_quorum (network_quorum)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -77,22 +83,22 @@ public:
|
||||
|
||||
// network information
|
||||
// Our best estimate of wall time in seconds from 1/1/2000
|
||||
std::uint32_t getNetworkTimeNC ();
|
||||
std::uint32_t getNetworkTimeNC () const;
|
||||
|
||||
// Our best estimate of current ledger close time
|
||||
std::uint32_t getCloseTimeNC ();
|
||||
std::uint32_t getCloseTimeNC () const;
|
||||
|
||||
// Use *only* to timestamp our own validation
|
||||
std::uint32_t getValidationTimeNC ();
|
||||
void closeTimeOffset (int);
|
||||
boost::posix_time::ptime getNetworkTimePT ();
|
||||
boost::posix_time::ptime getNetworkTimePT () const;
|
||||
std::uint32_t getLedgerID (uint256 const& hash);
|
||||
std::uint32_t getCurrentLedgerID ();
|
||||
OperatingMode getOperatingMode ()
|
||||
OperatingMode getOperatingMode () const
|
||||
{
|
||||
return mMode;
|
||||
}
|
||||
std::string strOperatingMode ();
|
||||
std::string strOperatingMode () const;
|
||||
|
||||
Ledger::pointer getClosedLedger ()
|
||||
{
|
||||
@@ -551,6 +557,14 @@ private:
|
||||
|
||||
std::uint32_t mLastLoadBase;
|
||||
std::uint32_t mLastLoadFactor;
|
||||
|
||||
JobQueue& m_job_queue;
|
||||
|
||||
// Whether we are in standalone mode
|
||||
bool const m_standalone;
|
||||
|
||||
// The number of nodes that we need to consider ourselves connected
|
||||
std::size_t const m_network_quorum;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -598,15 +612,14 @@ void NetworkOPsImp::processHeartbeatTimer ()
|
||||
std::size_t const numPeers = getApp().overlay ().size ();
|
||||
|
||||
// do we have sufficient peers? If not, we are disconnected.
|
||||
if (numPeers < getConfig ().NETWORK_QUORUM)
|
||||
if (numPeers < m_network_quorum)
|
||||
{
|
||||
if (mMode != omDISCONNECTED)
|
||||
{
|
||||
setMode (omDISCONNECTED);
|
||||
m_journal.warning
|
||||
<< "Node count (" << numPeers << ") "
|
||||
<< "has fallen below quorum ("
|
||||
<< getConfig ().NETWORK_QUORUM << ").";
|
||||
<< "has fallen below quorum (" << m_network_quorum << ").";
|
||||
}
|
||||
|
||||
setHeartbeatTimer ();
|
||||
@@ -678,9 +691,9 @@ void NetworkOPsImp::processClusterTimer ()
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
std::string NetworkOPsImp::strOperatingMode ()
|
||||
std::string NetworkOPsImp::strOperatingMode () const
|
||||
{
|
||||
static const char* paStatusToken [] =
|
||||
static char const* paStatusToken [] =
|
||||
{
|
||||
"disconnected",
|
||||
"connected",
|
||||
@@ -701,7 +714,7 @@ std::string NetworkOPsImp::strOperatingMode ()
|
||||
return paStatusToken[mMode];
|
||||
}
|
||||
|
||||
boost::posix_time::ptime NetworkOPsImp::getNetworkTimePT ()
|
||||
boost::posix_time::ptime NetworkOPsImp::getNetworkTimePT () const
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
@@ -712,12 +725,12 @@ boost::posix_time::ptime NetworkOPsImp::getNetworkTimePT ()
|
||||
boost::posix_time::seconds (offset);
|
||||
}
|
||||
|
||||
std::uint32_t NetworkOPsImp::getNetworkTimeNC ()
|
||||
std::uint32_t NetworkOPsImp::getNetworkTimeNC () const
|
||||
{
|
||||
return iToSeconds (getNetworkTimePT ());
|
||||
}
|
||||
|
||||
std::uint32_t NetworkOPsImp::getCloseTimeNC ()
|
||||
std::uint32_t NetworkOPsImp::getCloseTimeNC () const
|
||||
{
|
||||
return iToSeconds (getNetworkTimePT () +
|
||||
boost::posix_time::seconds (mCloseTimeOffset));
|
||||
@@ -1939,8 +1952,8 @@ NetworkOPs::AccountTxs NetworkOPsImp::getAccountTxs (
|
||||
minLedger, maxLedger, descending, offset, limit, false, false, bAdmin);
|
||||
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
auto db = getApp().getTxnDB ().getDB ();
|
||||
auto sl (getApp().getTxnDB ().lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
@@ -1994,8 +2007,8 @@ std::vector<NetworkOPsImp::txnMetaLedgerType> NetworkOPsImp::getAccountTxsB (
|
||||
bAdmin);
|
||||
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
auto db = getApp().getTxnDB ().getDB ();
|
||||
auto sl (getApp().getTxnDB ().lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
@@ -2091,8 +2104,8 @@ NetworkOPsImp::AccountTxs NetworkOPsImp::getTxsAccount (
|
||||
% (forward ? "ASC" : "DESC")
|
||||
% queryLimit);
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
auto db = getApp().getTxnDB ().getDB ();
|
||||
auto sl (getApp().getTxnDB ().lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
@@ -2209,8 +2222,8 @@ NetworkOPsImp::MetaTxsList NetworkOPsImp::getTxsAccountB (
|
||||
% (forward ? "ASC" : "DESC")
|
||||
% queryLimit);
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
auto db = getApp().getTxnDB ().getDB ();
|
||||
auto sl (getApp().getTxnDB ().lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
@@ -2281,8 +2294,8 @@ NetworkOPsImp::getLedgerAffectedAccounts (std::uint32_t ledgerSeq)
|
||||
% ledgerSeq);
|
||||
RippleAddress acct;
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
auto db = getApp().getTxnDB ().getDB ();
|
||||
auto sl (getApp().getTxnDB ().lock ());
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
if (acct.setAccountID (db->getStrBinary ("Account")))
|
||||
@@ -2963,10 +2976,10 @@ bool NetworkOPsImp::unsubLedger (std::uint64_t uSeq)
|
||||
bool NetworkOPsImp::subServer (InfoSub::ref isrListener, Json::Value& jvResult,
|
||||
bool admin)
|
||||
{
|
||||
uint256 uRandom;
|
||||
uint256 uRandom;
|
||||
|
||||
if (getConfig ().RUN_STANDALONE)
|
||||
jvResult[jss::stand_alone] = getConfig ().RUN_STANDALONE;
|
||||
if (m_standalone)
|
||||
jvResult[jss::stand_alone] = m_standalone;
|
||||
|
||||
RandomNumbers::getInstance ().fillBytes (uRandom.begin (), uRandom.size ());
|
||||
|
||||
@@ -3644,10 +3657,13 @@ NetworkOPs::~NetworkOPs ()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
NetworkOPs* NetworkOPs::New (clock_type& clock, LedgerMaster& ledgerMaster,
|
||||
Stoppable& parent, beast::Journal journal)
|
||||
std::unique_ptr<NetworkOPs>
|
||||
make_NetworkOPs (NetworkOPs::clock_type& clock, bool standalone,
|
||||
std::size_t network_quorum, JobQueue& job_queue, LedgerMaster& ledgerMaster,
|
||||
beast::Stoppable& parent, beast::Journal journal)
|
||||
{
|
||||
return new NetworkOPsImp (clock, ledgerMaster, parent, journal);
|
||||
return std::make_unique<NetworkOPsImp> (clock, standalone, network_quorum,
|
||||
job_queue, ledgerMaster, parent, journal);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef RIPPLE_NETWORKOPS_H
|
||||
#define RIPPLE_NETWORKOPS_H
|
||||
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
#include <tuple>
|
||||
|
||||
namespace ripple {
|
||||
@@ -84,11 +85,6 @@ public:
|
||||
typedef hash_map <std::uint64_t, InfoSub::wptr> SubMapType;
|
||||
|
||||
public:
|
||||
// VFALCO TODO Make LedgerMaster a SharedPtr or a reference.
|
||||
//
|
||||
static NetworkOPs* New (clock_type& clock, LedgerMaster& ledgerMaster,
|
||||
Stoppable& parent, beast::Journal journal);
|
||||
|
||||
virtual ~NetworkOPs () = 0;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -97,18 +93,18 @@ public:
|
||||
//
|
||||
|
||||
// Our best estimate of wall time in seconds from 1/1/2000
|
||||
virtual std::uint32_t getNetworkTimeNC () = 0;
|
||||
virtual std::uint32_t getNetworkTimeNC () const = 0;
|
||||
// Our best estimate of current ledger close time
|
||||
virtual std::uint32_t getCloseTimeNC () = 0;
|
||||
virtual std::uint32_t getCloseTimeNC () const = 0;
|
||||
// Use *only* to timestamp our own validation
|
||||
virtual std::uint32_t getValidationTimeNC () = 0;
|
||||
virtual void closeTimeOffset (int) = 0;
|
||||
virtual boost::posix_time::ptime getNetworkTimePT () = 0;
|
||||
virtual boost::posix_time::ptime getNetworkTimePT () const = 0;
|
||||
virtual std::uint32_t getLedgerID (uint256 const& hash) = 0;
|
||||
virtual std::uint32_t getCurrentLedgerID () = 0;
|
||||
|
||||
virtual OperatingMode getOperatingMode () = 0;
|
||||
virtual std::string strOperatingMode () = 0;
|
||||
virtual OperatingMode getOperatingMode () const = 0;
|
||||
virtual std::string strOperatingMode () const = 0;
|
||||
virtual Ledger::pointer getClosedLedger () = 0;
|
||||
virtual Ledger::pointer getValidatedLedger () = 0;
|
||||
virtual Ledger::pointer getPublishedLedger () = 0;
|
||||
@@ -325,6 +321,11 @@ public:
|
||||
SerializedTransaction::ref stTxn, TER terResult) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<NetworkOPs>
|
||||
make_NetworkOPs (NetworkOPs::clock_type& clock, bool standalone,
|
||||
std::size_t network_quorum, JobQueue& job_queue, LedgerMaster& ledgerMaster,
|
||||
beast::Stoppable& parent, beast::Journal journal);
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -354,7 +354,7 @@ private:
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr<ProofOfWorkFactory> ProofOfWorkFactory::New ()
|
||||
std::unique_ptr<ProofOfWorkFactory> make_ProofOfWorkFactory ()
|
||||
{
|
||||
return std::make_unique<ProofOfWorkFactoryImp>();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <ripple/module/app/misc/PowResult.h>
|
||||
#include <ripple/module/app/misc/ProofOfWork.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -33,8 +34,6 @@ public:
|
||||
kMaxDifficulty = 30,
|
||||
};
|
||||
|
||||
static std::unique_ptr<ProofOfWorkFactory> New ();
|
||||
|
||||
virtual ~ProofOfWorkFactory () { }
|
||||
|
||||
virtual ProofOfWork getProof () = 0;
|
||||
@@ -56,6 +55,8 @@ public:
|
||||
virtual void setSecret (uint256 const& secret) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<ProofOfWorkFactory> make_ProofOfWorkFactory ();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,14 +46,14 @@ SerializedLedgerEntry::SerializedLedgerEntry (
|
||||
|
||||
void SerializedLedgerEntry::setSLEType ()
|
||||
{
|
||||
auto type = static_cast <LedgerEntryType> (getFieldU16 (sfLedgerEntryType));
|
||||
auto const item = LedgerFormats::getInstance()->findByType (type);
|
||||
mFormat = LedgerFormats::getInstance()->findByType (
|
||||
static_cast <LedgerEntryType> (getFieldU16 (sfLedgerEntryType)));
|
||||
|
||||
if (item == nullptr)
|
||||
if (mFormat == nullptr)
|
||||
throw std::runtime_error ("invalid ledger entry type");
|
||||
|
||||
mType = item->getType ();
|
||||
if (!setType (item->elements))
|
||||
mType = mFormat->getType ();
|
||||
if (!setType (mFormat->elements))
|
||||
{
|
||||
WriteLog (lsWARNING, SerializedLedger)
|
||||
<< "Ledger entry not valid for type " << mFormat->getName ();
|
||||
@@ -65,19 +65,14 @@ void SerializedLedgerEntry::setSLEType ()
|
||||
SerializedLedgerEntry::SerializedLedgerEntry (LedgerEntryType type, uint256 const& index) :
|
||||
STObject (sfLedgerEntry), mIndex (index), mType (type), mMutable (true)
|
||||
{
|
||||
LedgerFormats::Item const* const item =
|
||||
LedgerFormats::getInstance()->findByType (type);
|
||||
mFormat = LedgerFormats::getInstance()->findByType (type);
|
||||
|
||||
if (item != nullptr)
|
||||
{
|
||||
set (item->elements);
|
||||
|
||||
setFieldU16 (sfLedgerEntryType, static_cast <std::uint16_t> (item->getType ()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mFormat == nullptr)
|
||||
throw std::runtime_error ("invalid ledger entry type");
|
||||
}
|
||||
|
||||
set (mFormat->elements);
|
||||
setFieldU16 (sfLedgerEntryType,
|
||||
static_cast <std::uint16_t> (mFormat->getType ()));
|
||||
}
|
||||
|
||||
SerializedLedgerEntry::pointer SerializedLedgerEntry::getMutable () const
|
||||
|
||||
@@ -159,7 +159,7 @@ std::vector<RippleAddress> SerializedTransaction::getMentionedAccounts () const
|
||||
|
||||
uint256 SerializedTransaction::getSigningHash () const
|
||||
{
|
||||
return STObject::getSigningHash (getConfig ().SIGN_TRANSACTION);
|
||||
return STObject::getSigningHash (HashPrefix::txSign);
|
||||
}
|
||||
|
||||
uint256 SerializedTransaction::getTransactionID () const
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <thread>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -436,8 +437,8 @@ private:
|
||||
{
|
||||
ScopedUnlockType sul (mLock);
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
auto dbl (getApp().getLedgerDB ()->lock ());
|
||||
auto db = getApp().getLedgerDB ().getDB ();
|
||||
auto dbl (getApp().getLedgerDB ().lock ());
|
||||
|
||||
Serializer s (1024);
|
||||
db->executeSQL ("BEGIN TRANSACTION;");
|
||||
@@ -465,9 +466,9 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
Validations* Validations::New ()
|
||||
std::unique_ptr <Validations> make_Validations ()
|
||||
{
|
||||
return new ValidationsImp;
|
||||
return std::make_unique <ValidationsImp> ();
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef RIPPLE_VALIDATIONS_H_INCLUDED
|
||||
#define RIPPLE_VALIDATIONS_H_INCLUDED
|
||||
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// VFALCO TODO rename and move these typedefs into the Validations interface
|
||||
@@ -34,7 +36,6 @@ typedef std::vector<SerializedValidation::pointer> ValidationVector;
|
||||
class Validations : beast::LeakChecked <Validations>
|
||||
{
|
||||
public:
|
||||
static Validations* New ();
|
||||
|
||||
virtual ~Validations () { }
|
||||
|
||||
@@ -70,6 +71,8 @@ public:
|
||||
virtual void sweep () = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr <Validations> make_Validations ();
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <beast/module/core/thread/DeadlineTimer.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -66,10 +67,7 @@ class UniqueNodeListImp
|
||||
, public beast::DeadlineTimer::Listener
|
||||
{
|
||||
private:
|
||||
// VFALCO TODO Rename these structs? Are they objects with static storage?
|
||||
// This looks like C and not C++...
|
||||
//
|
||||
typedef struct
|
||||
struct seedDomain
|
||||
{
|
||||
std::string strDomain;
|
||||
RippleAddress naPublicKey;
|
||||
@@ -79,9 +77,9 @@ private:
|
||||
boost::posix_time::ptime tpFetch;
|
||||
uint256 iSha256;
|
||||
std::string strComment;
|
||||
} seedDomain;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct seedNode
|
||||
{
|
||||
RippleAddress naPublicKey;
|
||||
ValidatorSource vsSource;
|
||||
@@ -90,10 +88,10 @@ private:
|
||||
boost::posix_time::ptime tpFetch;
|
||||
uint256 iSha256;
|
||||
std::string strComment;
|
||||
} seedNode;
|
||||
};
|
||||
|
||||
// Used to distribute scores.
|
||||
typedef struct
|
||||
struct scoreNode
|
||||
{
|
||||
int iScore;
|
||||
int iRoundScore;
|
||||
@@ -101,7 +99,7 @@ private:
|
||||
int iSeen;
|
||||
std::string strValidator; // The public key.
|
||||
std::vector<int> viReferrals;
|
||||
} scoreNode;
|
||||
};
|
||||
|
||||
typedef hash_map<std::string, int> strIndex;
|
||||
typedef std::pair<std::string, int> IPAndPortNumber;
|
||||
@@ -271,8 +269,8 @@ public:
|
||||
void nodeRemovePublic (RippleAddress const& naNodePublic)
|
||||
{
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
db->executeSQL (str (boost::format ("DELETE FROM SeedNodes WHERE PublicKey=%s") % sqlEscape (naNodePublic.humanNodePublic ())));
|
||||
db->executeSQL (str (boost::format ("DELETE FROM TrustedNodes WHERE PublicKey=%s") % sqlEscape (naNodePublic.humanNodePublic ())));
|
||||
@@ -293,8 +291,8 @@ public:
|
||||
boost::to_lower (strDomain);
|
||||
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
db->executeSQL (str (boost::format ("DELETE FROM SeedDomains WHERE Domain=%s") % sqlEscape (strDomain)));
|
||||
}
|
||||
@@ -308,9 +306,9 @@ public:
|
||||
void nodeReset ()
|
||||
{
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
// XXX Check results.
|
||||
db->executeSQL ("DELETE FROM SeedDomains");
|
||||
@@ -444,8 +442,8 @@ public:
|
||||
|
||||
#if 0
|
||||
{
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
if (db->executeSQL (str (boost::format ("SELECT COUNT(*) AS Count FROM SeedDomains WHERE Source='%s' OR Source='%c';") % vsManual % vsValidator)) && db->startIterRows ())
|
||||
iDomains = db->getInt ("Count");
|
||||
@@ -582,11 +580,11 @@ public:
|
||||
|
||||
Json::Value getUnlJson ()
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
Json::Value ret (Json::arrayValue);
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
SQL_FOREACH (db, "SELECT * FROM TrustedNodes;")
|
||||
{
|
||||
Json::Value node (Json::objectValue);
|
||||
@@ -649,15 +647,20 @@ private:
|
||||
// Load information about when we last updated.
|
||||
bool miscLoad ()
|
||||
{
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
if (!db->executeSQL ("SELECT * FROM Misc WHERE Magic=1;")) return false;
|
||||
if (!db->executeSQL ("SELECT * FROM Misc WHERE Magic=1;"))
|
||||
return false;
|
||||
|
||||
bool bAvail = db->startIterRows ();
|
||||
bool const bAvail = db->startIterRows ();
|
||||
|
||||
mtpFetchUpdated = ptFromSeconds (bAvail ? db->getInt ("FetchUpdated") : -1);
|
||||
mtpScoreUpdated = ptFromSeconds (bAvail ? db->getInt ("ScoreUpdated") : -1);
|
||||
mtpFetchUpdated = ptFromSeconds (bAvail
|
||||
? db->getInt ("FetchUpdated")
|
||||
: -1);
|
||||
mtpScoreUpdated = ptFromSeconds (bAvail
|
||||
? db->getInt ("ScoreUpdated")
|
||||
: -1);
|
||||
|
||||
db->endIterRows ();
|
||||
|
||||
@@ -671,8 +674,8 @@ private:
|
||||
// Persist update information.
|
||||
bool miscSave ()
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
db->executeSQL (str (boost::format ("REPLACE INTO Misc (Magic,FetchUpdated,ScoreUpdated) VALUES (1,%d,%d);")
|
||||
% iToSeconds (mtpFetchUpdated)
|
||||
@@ -701,8 +704,8 @@ private:
|
||||
WriteLog (lsWARNING, UniqueNodeList) << "Entry in cluster list invalid: '" << c << "'";
|
||||
}
|
||||
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
ScopedUNLLockType slUNL (mUNLLock);
|
||||
|
||||
mUNL.clear ();
|
||||
@@ -798,12 +801,12 @@ private:
|
||||
strIndex umDomainIdx; // Map of domain to index.
|
||||
std::vector<scoreNode> vsnNodes; // Index to scoring node.
|
||||
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
// For each entry in SeedDomains with a PublicKey:
|
||||
// - Add an entry in umPulicIdx, umDomainIdx, and vsnNodes.
|
||||
{
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
SQL_FOREACH (db, "SELECT Domain,PublicKey,Source FROM SeedDomains;")
|
||||
{
|
||||
@@ -856,7 +859,7 @@ private:
|
||||
// For each entry in SeedNodes:
|
||||
// - Add an entry in umPulicIdx, umDomainIdx, and vsnNodes.
|
||||
{
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
SQL_FOREACH (db, "SELECT PublicKey,Source FROM SeedNodes;")
|
||||
{
|
||||
@@ -920,7 +923,7 @@ private:
|
||||
std::string& strValidator = sn.strValidator;
|
||||
std::vector<int>& viReferrals = sn.viReferrals;
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
SQL_FOREACH (db, boost::str (boost::format ("SELECT Referral FROM ValidatorReferrals WHERE Validator=%s ORDER BY Entry;")
|
||||
% sqlEscape (strValidator)))
|
||||
@@ -1001,7 +1004,7 @@ private:
|
||||
}
|
||||
|
||||
// Persist validator scores.
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
db->executeSQL ("BEGIN;");
|
||||
db->executeSQL ("UPDATE TrustedNodes SET Score = 0 WHERE Score != 0;");
|
||||
@@ -1287,8 +1290,8 @@ private:
|
||||
boost::posix_time::ptime tpNext (boost::posix_time::min_date_time);
|
||||
boost::posix_time::ptime tpNow (boost::posix_time::second_clock::universal_time ());
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
if (db->executeSQL ("SELECT Domain,Next FROM SeedDomains INDEXED BY SeedDomainNext ORDER BY Next LIMIT 1;")
|
||||
&& db->startIterRows ())
|
||||
@@ -1549,7 +1552,7 @@ private:
|
||||
// --> naNodePublic: public key of the validating node.
|
||||
void processIps (std::string const& strSite, RippleAddress const& naNodePublic, Section::mapped_type* pmtVecStrIps)
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
std::string strEscNodePublic = sqlEscape (naNodePublic.humanNodePublic ());
|
||||
|
||||
@@ -1559,7 +1562,7 @@ private:
|
||||
|
||||
// Remove all current Validator's entries in IpReferrals
|
||||
{
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
db->executeSQL (str (boost::format ("DELETE FROM IpReferrals WHERE Validator=%s;") % strEscNodePublic));
|
||||
// XXX Check result.
|
||||
}
|
||||
@@ -1602,7 +1605,7 @@ private:
|
||||
{
|
||||
vstrValues.resize (iValues);
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
db->executeSQL (str (boost::format ("INSERT INTO IpReferrals (Validator,Entry,IP,Port) VALUES %s;")
|
||||
% strJoin (vstrValues.begin (), vstrValues.end (), ",")));
|
||||
// XXX Check result.
|
||||
@@ -1621,7 +1624,7 @@ private:
|
||||
// --> vsWhy: reason for adding validator to SeedDomains or SeedNodes.
|
||||
int processValidators (std::string const& strSite, std::string const& strValidatorsSrc, RippleAddress const& naNodePublic, ValidatorSource vsWhy, Section::mapped_type* pmtVecStrValidators)
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
std::string strNodePublic = naNodePublic.isValid () ? naNodePublic.humanNodePublic () : strValidatorsSrc;
|
||||
int iValues = 0;
|
||||
|
||||
@@ -1633,7 +1636,7 @@ private:
|
||||
|
||||
// Remove all current Validator's entries in ValidatorReferrals
|
||||
{
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
db->executeSQL (str (boost::format ("DELETE FROM ValidatorReferrals WHERE Validator='%s';") % strNodePublic));
|
||||
// XXX Check result.
|
||||
@@ -1704,7 +1707,7 @@ private:
|
||||
std::string strSql = str (boost::format ("INSERT INTO ValidatorReferrals (Validator,Entry,Referral) VALUES %s;")
|
||||
% strJoin (vstrValues.begin (), vstrValues.end (), ","));
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
db->executeSQL (strSql);
|
||||
// XXX Check result.
|
||||
@@ -1751,12 +1754,12 @@ private:
|
||||
bool getSeedDomains (std::string const& strDomain, seedDomain& dstSeedDomain)
|
||||
{
|
||||
bool bResult;
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
std::string strSql = boost::str (boost::format ("SELECT * FROM SeedDomains WHERE Domain=%s;")
|
||||
% sqlEscape (strDomain));
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
bResult = db->executeSQL (strSql) && db->startIterRows ();
|
||||
|
||||
@@ -1811,7 +1814,7 @@ private:
|
||||
// Persist a SeedDomain.
|
||||
void setSeedDomains (const seedDomain& sdSource, bool bNext)
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
int iNext = iToSeconds (sdSource.tpNext);
|
||||
int iScan = iToSeconds (sdSource.tpScan);
|
||||
@@ -1830,7 +1833,7 @@ private:
|
||||
% sqlEscape (sdSource.strComment)
|
||||
);
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
if (!db->executeSQL (strSql))
|
||||
{
|
||||
@@ -1852,12 +1855,12 @@ private:
|
||||
bool getSeedNodes (RippleAddress const& naNodePublic, seedNode& dstSeedNode)
|
||||
{
|
||||
bool bResult;
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
std::string strSql = str (boost::format ("SELECT * FROM SeedNodes WHERE PublicKey='%s';")
|
||||
% naNodePublic.humanNodePublic ());
|
||||
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
bResult = db->executeSQL (strSql) && db->startIterRows ();
|
||||
|
||||
@@ -1912,7 +1915,7 @@ private:
|
||||
// <-- bNext: true, to do fetching if needed.
|
||||
void setSeedNodes (const seedNode& snSource, bool bNext)
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
auto db = getApp().getWalletDB ().getDB ();
|
||||
|
||||
int iNext = iToSeconds (snSource.tpNext);
|
||||
int iScan = iToSeconds (snSource.tpScan);
|
||||
@@ -1933,7 +1936,7 @@ private:
|
||||
);
|
||||
|
||||
{
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
auto sl (getApp().getWalletDB ().lock ());
|
||||
|
||||
if (!db->executeSQL (strSql))
|
||||
{
|
||||
@@ -2048,9 +2051,10 @@ UniqueNodeList::UniqueNodeList (Stoppable& parent)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
UniqueNodeList* UniqueNodeList::New (Stoppable& parent)
|
||||
std::unique_ptr<UniqueNodeList>
|
||||
make_UniqueNodeList (beast::Stoppable& parent)
|
||||
{
|
||||
return new UniqueNodeListImp (parent);
|
||||
return std::make_unique<UniqueNodeListImp> (parent);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef RIPPLE_UNIQUENODELIST_H_INCLUDED
|
||||
#define RIPPLE_UNIQUENODELIST_H_INCLUDED
|
||||
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class UniqueNodeList : public beast::Stoppable
|
||||
@@ -43,9 +45,6 @@ public:
|
||||
typedef long score;
|
||||
|
||||
public:
|
||||
// VFALCO TODO make this not use boost::asio...
|
||||
static UniqueNodeList* New (Stoppable& parent);
|
||||
|
||||
virtual ~UniqueNodeList () { }
|
||||
|
||||
// VFALCO TODO Roll this into the constructor so there is one less state.
|
||||
@@ -77,6 +76,9 @@ public:
|
||||
virtual int iSourceScore (ValidatorSource vsWhy) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<UniqueNodeList>
|
||||
make_UniqueNodeList (beast::Stoppable& parent);
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -205,8 +205,8 @@ Transaction::pointer Transaction::transactionFromSQL (std::string const& sql)
|
||||
rawTxn.resize (txSize);
|
||||
|
||||
{
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
auto sl (getApp().getTxnDB ().lock ());
|
||||
auto db = getApp().getTxnDB ().getDB ();
|
||||
|
||||
if (!db->executeSQL (sql, true) || !db->startIterRows ())
|
||||
return Transaction::pointer ();
|
||||
|
||||
@@ -173,10 +173,6 @@ void Config::setup (std::string const& strConf, bool bQuiet)
|
||||
|
||||
VALIDATORS_URI = boost::str (boost::format ("/%s") % VALIDATORS_BASE);
|
||||
|
||||
SIGN_TRANSACTION = HashPrefix::txSign;
|
||||
SIGN_VALIDATION = HashPrefix::validation;
|
||||
SIGN_PROPOSAL = HashPrefix::proposal;
|
||||
|
||||
if (!strConf.empty ())
|
||||
{
|
||||
// --conf=<path> : everything is relative that file.
|
||||
@@ -513,7 +509,7 @@ void Config::load ()
|
||||
PEER_CONNECT_LOW_WATER = std::max (1, beast::lexicalCastThrow <int> (strTemp));
|
||||
|
||||
if (SectionSingleB (secConfig, SECTION_NETWORK_QUORUM, strTemp))
|
||||
NETWORK_QUORUM = std::max (0, beast::lexicalCastThrow <int> (strTemp));
|
||||
NETWORK_QUORUM = beast::lexicalCastThrow <std::size_t> (strTemp);
|
||||
|
||||
if (SectionSingleB (secConfig, SECTION_VALIDATION_QUORUM, strTemp))
|
||||
VALIDATION_QUORUM = std::max (0, beast::lexicalCastThrow <int> (strTemp));
|
||||
|
||||
@@ -384,8 +384,6 @@ public:
|
||||
int NETWORK_START_TIME; // The Unix time we start ledger 0.
|
||||
int TRANSACTION_FEE_BASE; // The number of fee units a reference transaction costs
|
||||
int LEDGER_SECONDS;
|
||||
int LEDGER_PROPOSAL_DELAY_SECONDS;
|
||||
int LEDGER_AVALANCHE_SECONDS;
|
||||
bool LEDGER_CREATOR; // Should be false unless we are starting a new ledger.
|
||||
|
||||
/** Operate in stand-alone mode.
|
||||
@@ -400,7 +398,7 @@ public:
|
||||
bool RUN_STANDALONE;
|
||||
|
||||
// Note: The following parameters do not relate to the UNL or trust at all
|
||||
unsigned int NETWORK_QUORUM; // Minimum number of nodes to consider the network present
|
||||
std::size_t NETWORK_QUORUM; // Minimum number of nodes to consider the network present
|
||||
int VALIDATION_QUORUM; // Minimum validations to consider ledger authoritative
|
||||
|
||||
// Peer networking parameters
|
||||
@@ -474,11 +472,6 @@ public:
|
||||
// Client behavior
|
||||
int ACCOUNT_PROBE_MAX; // How far to scan for accounts.
|
||||
|
||||
// Signing signatures.
|
||||
std::uint32_t SIGN_TRANSACTION;
|
||||
std::uint32_t SIGN_VALIDATION;
|
||||
std::uint32_t SIGN_PROPOSAL;
|
||||
|
||||
bool SSL_VERIFY;
|
||||
std::string SSL_VERIFY_FILE;
|
||||
std::string SSL_VERIFY_DIR;
|
||||
|
||||
@@ -75,6 +75,17 @@ std::string RippleAddress::humanAddressType () const
|
||||
// NodePublic
|
||||
//
|
||||
|
||||
uint160 Hash160 (Blob const& vch)
|
||||
{
|
||||
uint256 hash1;
|
||||
SHA256 (vch.data (), vch.size (), hash1.data ());
|
||||
|
||||
uint160 hash2;
|
||||
RIPEMD160 (hash1.data (), hash1.size (), hash2.data ());
|
||||
|
||||
return hash2;
|
||||
}
|
||||
|
||||
RippleAddress RippleAddress::createNodePublic (RippleAddress const& naSeed)
|
||||
{
|
||||
CKey ckSeed (naSeed.getSeed ());
|
||||
|
||||
@@ -43,17 +43,18 @@ Json::Value doGetCounts (RPC::Context& context)
|
||||
}
|
||||
|
||||
Application& app = getApp();
|
||||
int dbKB = app.getLedgerDB ()->getDB ()->getKBUsedAll ();
|
||||
|
||||
int dbKB = app.getLedgerDB ().getDB ()->getKBUsedAll ();
|
||||
|
||||
if (dbKB > 0)
|
||||
ret["dbKBTotal"] = dbKB;
|
||||
|
||||
dbKB = app.getLedgerDB ()->getDB ()->getKBUsedDB ();
|
||||
dbKB = app.getLedgerDB ().getDB ()->getKBUsedDB ();
|
||||
|
||||
if (dbKB > 0)
|
||||
ret["dbKBLedger"] = dbKB;
|
||||
|
||||
dbKB = app.getTxnDB ()->getDB ()->getKBUsedDB ();
|
||||
dbKB = app.getTxnDB ().getDB ()->getKBUsedDB ();
|
||||
|
||||
if (dbKB > 0)
|
||||
ret["dbKBTransaction"] = dbKB;
|
||||
|
||||
@@ -35,7 +35,7 @@ Json::Value doProofCreate (RPC::Context& context)
|
||||
context.params_.isMember ("secret"))
|
||||
{
|
||||
// VFALCO TODO why aren't we using the app's factory?
|
||||
auto pgGen = ProofOfWorkFactory::New ();
|
||||
auto pgGen = make_ProofOfWorkFactory ();
|
||||
|
||||
if (context.params_.isMember ("difficulty"))
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ Json::Value doProofVerify (RPC::Context& context)
|
||||
context.params_.isMember ("secret"))
|
||||
{
|
||||
// VFALCO TODO why aren't we using the app's factory?
|
||||
auto pgGen (ProofOfWorkFactory::New ());
|
||||
auto pgGen = make_ProofOfWorkFactory ();
|
||||
|
||||
if (context.params_.isMember ("difficulty"))
|
||||
{
|
||||
|
||||
@@ -46,8 +46,8 @@ Json::Value doTxHistory (RPC::Context& context)
|
||||
% startIndex);
|
||||
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
auto db = getApp().getTxnDB ().getDB ();
|
||||
auto sl (getApp().getTxnDB ().lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
|
||||
@@ -73,11 +73,6 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
maxLoopCount = 10000
|
||||
};
|
||||
|
||||
void testDrop (beast::Journal j)
|
||||
{
|
||||
testcase ("Warn/drop");
|
||||
@@ -92,8 +87,9 @@ public:
|
||||
Consumer c (logic.newInboundEndpoint (addr));
|
||||
|
||||
// Create load until we get a warning
|
||||
std::size_t n (maxLoopCount);
|
||||
while (--n > 0)
|
||||
int n = 10000;
|
||||
|
||||
while (--n >= 0)
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
@@ -110,7 +106,7 @@ public:
|
||||
}
|
||||
|
||||
// Create load until we get dropped
|
||||
while (--n > 0)
|
||||
while (--n >= 0)
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_SSLUTIL_HASHUTILITIES_H_INCLUDED
|
||||
#define RIPPLE_SSLUTIL_HASHUTILITIES_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// VFALCO NOTE these came from BitcoinUtil.h
|
||||
|
||||
// VFALCO TODO Rewrite the callers so we don't need templates,
|
||||
// then define these in a .cpp so they are no longer inline.
|
||||
//
|
||||
template<typename T1>
|
||||
uint256 SHA256Hash (const T1 pbegin, const T1 pend)
|
||||
{
|
||||
static unsigned char pblank[1];
|
||||
uint256 hash1;
|
||||
SHA256 ((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof (pbegin[0]), (unsigned char*)&hash1);
|
||||
uint256 hash2;
|
||||
SHA256 ((unsigned char*)&hash1, sizeof (hash1), (unsigned char*)&hash2);
|
||||
return hash2;
|
||||
}
|
||||
|
||||
template<typename T1, typename T2>
|
||||
uint256 SHA256Hash (const T1 p1begin, const T1 p1end,
|
||||
const T2 p2begin, const T2 p2end)
|
||||
{
|
||||
static unsigned char pblank[1];
|
||||
uint256 hash1;
|
||||
SHA256_CTX ctx;
|
||||
SHA256_Init (&ctx);
|
||||
SHA256_Update (&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof (p1begin[0]));
|
||||
SHA256_Update (&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof (p2begin[0]));
|
||||
SHA256_Final ((unsigned char*)&hash1, &ctx);
|
||||
uint256 hash2;
|
||||
SHA256 ((unsigned char*)&hash1, sizeof (hash1), (unsigned char*)&hash2);
|
||||
return hash2;
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3>
|
||||
uint256 SHA256Hash (const T1 p1begin, const T1 p1end,
|
||||
const T2 p2begin, const T2 p2end,
|
||||
const T3 p3begin, const T3 p3end)
|
||||
{
|
||||
static unsigned char pblank[1];
|
||||
uint256 hash1;
|
||||
SHA256_CTX ctx;
|
||||
SHA256_Init (&ctx);
|
||||
SHA256_Update (&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof (p1begin[0]));
|
||||
SHA256_Update (&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof (p2begin[0]));
|
||||
SHA256_Update (&ctx, (p3begin == p3end ? pblank : (unsigned char*)&p3begin[0]), (p3end - p3begin) * sizeof (p3begin[0]));
|
||||
SHA256_Final ((unsigned char*)&hash1, &ctx);
|
||||
uint256 hash2;
|
||||
SHA256 ((unsigned char*)&hash1, sizeof (hash1), (unsigned char*)&hash2);
|
||||
return hash2;
|
||||
}
|
||||
|
||||
uint160 Hash160 (Blob const& vch);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,57 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace ripple {
|
||||
|
||||
uint160 Hash160 (Blob const& vch)
|
||||
{
|
||||
uint256 hash1;
|
||||
SHA256 (&vch[0], vch.size (), (unsigned char*)&hash1);
|
||||
uint160 hash2;
|
||||
RIPEMD160 ((unsigned char*)&hash1, sizeof (hash1), (unsigned char*)&hash2);
|
||||
return hash2;
|
||||
}
|
||||
|
||||
/*
|
||||
#if BEAST_WIN32
|
||||
// This is used to attempt to keep keying material out of swap
|
||||
// Note that VirtualLock does not provide this as a guarantee on Windows,
|
||||
// but, in practice, memory that has been VirtualLock'd almost never gets written to
|
||||
// the pagefile except in rare circumstances where memory is extremely low.
|
||||
#include <windows.h>
|
||||
#define mlock(p, n) VirtualLock((p), (n));
|
||||
#define munlock(p, n) VirtualUnlock((p), (n));
|
||||
#else
|
||||
#include <sys/mman.h>
|
||||
#include <limits.h>
|
||||
// This comes from limits.h if it's not defined there set a sane default
|
||||
#ifndef PAGESIZE
|
||||
#include <unistd.h>
|
||||
#define PAGESIZE sysconf(_SC_PAGESIZE)
|
||||
#endif
|
||||
#define mlock(a,b) \
|
||||
mlock(((void *)(((size_t)(a)) & (~((PAGESIZE)-1)))),\
|
||||
(((((size_t)(a)) + (b) - 1) | ((PAGESIZE) - 1)) + 1) - (((size_t)(a)) & (~((PAGESIZE) - 1))))
|
||||
#define munlock(a,b) \
|
||||
munlock(((void *)(((size_t)(a)) & (~((PAGESIZE)-1)))),\
|
||||
(((((size_t)(a)) + (b) - 1) | ((PAGESIZE) - 1)) + 1) - (((size_t)(a)) & (~((PAGESIZE) - 1))))
|
||||
#endif
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -24,10 +24,20 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
uint256 SHA256Hash (unsigned char const* pbegin, unsigned char const* pend)
|
||||
{
|
||||
uint256 hash1;
|
||||
SHA256 (pbegin, pend - pbegin, hash1.begin ());
|
||||
|
||||
uint256 hash2;
|
||||
SHA256 (hash1.begin (), hash1.size (), hash2.begin());
|
||||
|
||||
return hash2;
|
||||
}
|
||||
|
||||
void Base58::fourbyte_hash256 (void* out, void const* in, std::size_t bytes)
|
||||
{
|
||||
unsigned char const* const p (
|
||||
static_cast <unsigned char const*>(in));
|
||||
auto p = static_cast <unsigned char const*>(in);
|
||||
uint256 hash (SHA256Hash (p, p + bytes));
|
||||
memcpy (out, hash.begin(), 4);
|
||||
}
|
||||
@@ -214,13 +224,15 @@ bool Base58::decodeWithCheck (const char* psz, Blob& vchRet, Alphabet const& alp
|
||||
if (!decode (psz, vchRet, alphabet))
|
||||
return false;
|
||||
|
||||
if (vchRet.size () < 4)
|
||||
auto size = vchRet.size ();
|
||||
|
||||
if (size < 4)
|
||||
{
|
||||
vchRet.clear ();
|
||||
return false;
|
||||
}
|
||||
|
||||
uint256 hash = SHA256Hash (vchRet.begin (), vchRet.end () - 4);
|
||||
uint256 hash = SHA256Hash (vchRet.data (), vchRet.data () + size - 4);
|
||||
|
||||
if (memcmp (&hash, &vchRet.end ()[-4], 4) != 0)
|
||||
{
|
||||
@@ -228,7 +240,7 @@ bool Base58::decodeWithCheck (const char* psz, Blob& vchRet, Alphabet const& alp
|
||||
return false;
|
||||
}
|
||||
|
||||
vchRet.resize (vchRet.size () - 4);
|
||||
vchRet.resize (size - 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,4 +24,3 @@
|
||||
#include <ripple/sslutil/impl/CBigNum.cpp>
|
||||
#include <ripple/sslutil/impl/ECDSACanonical.cpp>
|
||||
#include <ripple/sslutil/impl/DHUtil.cpp>
|
||||
#include <ripple/sslutil/impl/HashUtilities.cpp>
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <ripple/sslutil/api/CAutoBN_CTX.h>
|
||||
#include <ripple/sslutil/api/CBigNum.h>
|
||||
#include <ripple/sslutil/api/DHUtil.h>
|
||||
#include <ripple/sslutil/api/HashUtilities.h>
|
||||
#include <ripple/sslutil/api/ECDSACanonical.h>
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user