mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Simplify locking and move a typedef.
* Make DatabaseCon's lock private and expose a scoped lock_guard. * Get rid of DeprecatedRecursiveMutex and DeprecatedScopedLock entirely. * Move CancelCallback to Job where it logically belongs.
This commit is contained in:
committed by
Vinnie Falco
parent
02c2029ac1
commit
6335e34395
@@ -30,14 +30,8 @@ namespace ripple {
|
||||
typedef std::mutex RippleMutex;
|
||||
typedef std::recursive_mutex RippleRecursiveMutex;
|
||||
|
||||
typedef std::recursive_mutex DeprecatedRecursiveMutex;
|
||||
typedef std::lock_guard<DeprecatedRecursiveMutex> DeprecatedScopedLock;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** A callback used to check for canceling an operation. */
|
||||
typedef std::function <bool(void)> CancelCallback;
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef RIPPLE_DATABASECON_H
|
||||
#define RIPPLE_DATABASECON_H
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// VFALCO NOTE This looks like a pointless class. Figure out
|
||||
@@ -29,22 +31,24 @@ class DatabaseCon : beast::LeakChecked <DatabaseCon>
|
||||
public:
|
||||
DatabaseCon (const std::string& name, const char* initString[], int countInit);
|
||||
~DatabaseCon ();
|
||||
|
||||
Database* getDB ()
|
||||
{
|
||||
return mDatabase;
|
||||
}
|
||||
DeprecatedRecursiveMutex& getDBLock ()
|
||||
|
||||
typedef std::recursive_mutex mutex;
|
||||
|
||||
std::unique_lock<mutex> lock()
|
||||
{
|
||||
return mLock;
|
||||
return std::unique_lock<mutex>(mLock);
|
||||
}
|
||||
|
||||
// VFALCO TODO change "protected" to "private" throughout the code
|
||||
private:
|
||||
Database* mDatabase;
|
||||
DeprecatedRecursiveMutex mLock;
|
||||
Database* mDatabase;
|
||||
mutex mLock;
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -683,14 +683,14 @@ bool Ledger::saveValidatedLedger (bool current)
|
||||
}
|
||||
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getLedgerDB ()->getDBLock ());
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
getApp().getLedgerDB ()->getDB ()->executeSQL (
|
||||
boost::str (deleteLedger % mLedgerSeq));
|
||||
}
|
||||
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
DeprecatedScopedLock dbLock (getApp().getTxnDB ()->getDBLock ());
|
||||
auto dbLock (getApp().getTxnDB ()->lock ());
|
||||
db->executeSQL ("BEGIN TRANSACTION;");
|
||||
|
||||
db->executeSQL (boost::str (deleteTrans1 % getLedgerSeq ()));
|
||||
@@ -763,7 +763,7 @@ bool Ledger::saveValidatedLedger (bool current)
|
||||
}
|
||||
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getLedgerDB ()->getDBLock ());
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
|
||||
// TODO(tom): ARG!!
|
||||
getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (addLedger %
|
||||
@@ -789,7 +789,7 @@ Ledger::pointer Ledger::loadByIndex (std::uint32_t ledgerIndex)
|
||||
Ledger::pointer ledger;
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getLedgerDB ()->getDBLock ());
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
|
||||
SqliteStatement pSt (
|
||||
db->getSqliteDB (), "SELECT "
|
||||
@@ -815,7 +815,7 @@ Ledger::pointer Ledger::loadByHash (uint256 const& ledgerHash)
|
||||
Ledger::pointer ledger;
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getLedgerDB ()->getDBLock ());
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
|
||||
SqliteStatement pSt (
|
||||
db->getSqliteDB (), "SELECT "
|
||||
@@ -872,7 +872,7 @@ Ledger::pointer Ledger::getSQL (const std::string& sql)
|
||||
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getLedgerDB ()->getDBLock ());
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
|
||||
if (!db->executeSQL (sql) || !db->startIterRows ())
|
||||
return Ledger::pointer ();
|
||||
@@ -997,7 +997,7 @@ uint256 Ledger::getHashByIndex (std::uint32_t ledgerIndex)
|
||||
std::string hash;
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getLedgerDB ()->getDBLock ());
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
|
||||
if (!db->executeSQL (sql) || !db->startIterRows ())
|
||||
return ret;
|
||||
@@ -1016,7 +1016,7 @@ bool Ledger::getHashesByIndex (
|
||||
#ifndef NO_SQLITE3_PREPARE
|
||||
|
||||
DatabaseCon* con = getApp().getLedgerDB ();
|
||||
DeprecatedScopedLock sl (con->getDBLock ());
|
||||
auto sl (con->lock ());
|
||||
|
||||
SqliteStatement pSt (con->getDB ()->getSqliteDB (),
|
||||
"SELECT LedgerHash,PrevHash FROM Ledgers "
|
||||
@@ -1054,7 +1054,7 @@ bool Ledger::getHashesByIndex (
|
||||
std::string hash, prevHash;
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getLedgerDB ()->getDBLock ());
|
||||
auto sl (getApp().getLedgerDB ()->lock ());
|
||||
|
||||
if (!db->executeSQL (sql) || !db->startIterRows ())
|
||||
return false;
|
||||
@@ -1088,7 +1088,7 @@ Ledger::getHashesByIndex (std::uint32_t minSeq, std::uint32_t maxSeq)
|
||||
sql.append (";");
|
||||
|
||||
DatabaseCon* con = getApp().getLedgerDB ();
|
||||
DeprecatedScopedLock sl (con->getDBLock ());
|
||||
auto sl (con->lock ());
|
||||
|
||||
SqliteStatement pSt (con->getDB ()->getSqliteDB (), sql);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void LocalCredentials::start ()
|
||||
bool LocalCredentials::nodeIdentityLoad ()
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
bool bSuccess = false;
|
||||
|
||||
if (db->executeSQL ("SELECT * FROM NodeIdentity;") && db->startIterRows ())
|
||||
@@ -106,7 +106,7 @@ bool LocalCredentials::nodeIdentityCreate ()
|
||||
//
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
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 ()
|
||||
@@ -124,7 +124,7 @@ bool LocalCredentials::dataDelete (const std::string& strKey)
|
||||
{
|
||||
Database* db = getApp().getRpcDB ()->getDB ();
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getRpcDB ()->getDBLock ());
|
||||
auto sl (getApp().getRpcDB ()->lock ());
|
||||
|
||||
return db->executeSQL (str (boost::format ("DELETE FROM RPCData WHERE Key=%s;")
|
||||
% sqlEscape (strKey)));
|
||||
@@ -134,7 +134,7 @@ bool LocalCredentials::dataFetch (const std::string& strKey, std::string& strVal
|
||||
{
|
||||
Database* db = getApp().getRpcDB ()->getDB ();
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getRpcDB ()->getDBLock ());
|
||||
auto sl (getApp().getRpcDB ()->lock ());
|
||||
|
||||
bool bSuccess = false;
|
||||
|
||||
@@ -156,7 +156,7 @@ bool LocalCredentials::dataStore (const std::string& strKey, const std::string&
|
||||
{
|
||||
Database* db = getApp().getRpcDB ()->getDB ();
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getRpcDB ()->getDBLock ());
|
||||
auto sl (getApp().getRpcDB ()->lock ());
|
||||
|
||||
bool bSuccess = false;
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ AmendmentTableImpl::getCreate (uint256 const& amendmentHash, bool create)
|
||||
query.append (to_string (amendmentHash));
|
||||
query.append ("';");
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
|
||||
if (db->executeSQL (query) && db->startIterRows ())
|
||||
@@ -373,7 +373,7 @@ AmendmentTableImpl::reportValidations (const AmendmentSet& set)
|
||||
|
||||
if (!changedAmendments.empty())
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
|
||||
db->executeSQL ("BEGIN TRANSACTION;");
|
||||
|
||||
@@ -1918,7 +1918,7 @@ NetworkOPs::AccountTxs NetworkOPsImp::getAccountTxs (
|
||||
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getTxnDB ()->getDBLock ());
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
@@ -1967,7 +1967,7 @@ std::vector<NetworkOPsImp::txnMetaLedgerType> NetworkOPsImp::getAccountTxsB (
|
||||
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getTxnDB ()->getDBLock ());
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
@@ -2060,7 +2060,7 @@ NetworkOPsImp::getTxsAccount (const RippleAddress& account, std::int32_t minLedg
|
||||
% queryLimit);
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getTxnDB ()->getDBLock ());
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
@@ -2168,7 +2168,7 @@ NetworkOPsImp::getTxsAccountB (const RippleAddress& account, std::int32_t minLed
|
||||
% queryLimit);
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getTxnDB ()->getDBLock ());
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
@@ -2231,7 +2231,7 @@ NetworkOPsImp::getLedgerAffectedAccounts (std::uint32_t ledgerSeq)
|
||||
RippleAddress acct;
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getTxnDB ()->getDBLock ());
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
if (acct.setAccountID (db->getStrBinary ("Account")))
|
||||
|
||||
@@ -437,7 +437,7 @@ private:
|
||||
ScopedUnlockType sul (mLock);
|
||||
{
|
||||
Database* db = getApp().getLedgerDB ()->getDB ();
|
||||
DeprecatedScopedLock dbl (getApp().getLedgerDB ()->getDBLock ());
|
||||
auto dbl (getApp().getLedgerDB ()->lock ());
|
||||
|
||||
Serializer s (1024);
|
||||
db->executeSQL ("BEGIN TRANSACTION;");
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
pObject->reset ();
|
||||
|
||||
{
|
||||
DeprecatedScopedLock sl (m_db->getDBLock());
|
||||
auto sl (m_db->lock());
|
||||
|
||||
uint256 const hash (uint256::fromVoid (key));
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
{
|
||||
// VFALCO TODO Rewrite this to use Beast::db
|
||||
|
||||
DeprecatedScopedLock sl (m_db->getDBLock());
|
||||
auto sl (m_db->lock());
|
||||
|
||||
static SqliteStatement pStB (m_db->getDB()->getSqliteDB(), "BEGIN TRANSACTION;");
|
||||
static SqliteStatement pStE (m_db->getDB()->getSqliteDB(), "END TRANSACTION;");
|
||||
|
||||
@@ -44,7 +44,8 @@ RippleLineCache::pointer PathRequests::getLineCache (Ledger::pointer& ledger, bo
|
||||
return mLineCache;
|
||||
}
|
||||
|
||||
void PathRequests::updateAll (Ledger::ref inLedger, CancelCallback shouldCancel)
|
||||
void PathRequests::updateAll (Ledger::ref inLedger,
|
||||
Job::CancelCallback shouldCancel)
|
||||
{
|
||||
std::vector<PathRequest::wptr> requests;
|
||||
|
||||
|
||||
@@ -33,9 +33,11 @@ public:
|
||||
mFull = collector->make_event ("pathfind_full");
|
||||
}
|
||||
|
||||
void updateAll (const std::shared_ptr<Ledger>& ledger, CancelCallback shouldCancel);
|
||||
void updateAll (const std::shared_ptr<Ledger>& ledger,
|
||||
Job::CancelCallback shouldCancel);
|
||||
|
||||
RippleLineCache::pointer getLineCache (Ledger::pointer& ledger, bool authoritative);
|
||||
RippleLineCache::pointer getLineCache (
|
||||
Ledger::pointer& ledger, bool authoritative);
|
||||
|
||||
Json::Value makePathRequest (
|
||||
std::shared_ptr <InfoSub> const& subscriber,
|
||||
|
||||
@@ -272,7 +272,7 @@ public:
|
||||
{
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
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 ())));
|
||||
@@ -294,7 +294,7 @@ public:
|
||||
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
db->executeSQL (str (boost::format ("DELETE FROM SeedDomains WHERE Domain=%s") % sqlEscape (strDomain)));
|
||||
}
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
// XXX Check results.
|
||||
db->executeSQL ("DELETE FROM SeedDomains");
|
||||
@@ -444,7 +444,7 @@ public:
|
||||
|
||||
#if 0
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* 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 ())
|
||||
@@ -586,7 +586,7 @@ public:
|
||||
|
||||
Json::Value ret (Json::arrayValue);
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
SQL_FOREACH (db, "SELECT * FROM TrustedNodes;")
|
||||
{
|
||||
Json::Value node (Json::objectValue);
|
||||
@@ -649,7 +649,7 @@ private:
|
||||
// Load information about when we last updated.
|
||||
bool miscLoad ()
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
|
||||
if (!db->executeSQL ("SELECT * FROM Misc WHERE Magic=1;")) return false;
|
||||
@@ -672,7 +672,7 @@ private:
|
||||
bool miscSave ()
|
||||
{
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
db->executeSQL (str (boost::format ("REPLACE INTO Misc (Magic,FetchUpdated,ScoreUpdated) VALUES (1,%d,%d);")
|
||||
% iToSeconds (mtpFetchUpdated)
|
||||
@@ -702,7 +702,7 @@ private:
|
||||
}
|
||||
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
ScopedUNLLockType slUNL (mUNLLock);
|
||||
|
||||
mUNL.clear ();
|
||||
@@ -803,7 +803,7 @@ private:
|
||||
// For each entry in SeedDomains with a PublicKey:
|
||||
// - Add an entry in umPulicIdx, umDomainIdx, and vsnNodes.
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
SQL_FOREACH (db, "SELECT Domain,PublicKey,Source FROM SeedDomains;")
|
||||
{
|
||||
@@ -856,7 +856,7 @@ private:
|
||||
// For each entry in SeedNodes:
|
||||
// - Add an entry in umPulicIdx, umDomainIdx, and vsnNodes.
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
SQL_FOREACH (db, "SELECT PublicKey,Source FROM SeedNodes;")
|
||||
{
|
||||
@@ -920,7 +920,7 @@ private:
|
||||
std::string& strValidator = sn.strValidator;
|
||||
std::vector<int>& viReferrals = sn.viReferrals;
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
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 +1001,7 @@ private:
|
||||
}
|
||||
|
||||
// Persist validator scores.
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
db->executeSQL ("BEGIN;");
|
||||
db->executeSQL ("UPDATE TrustedNodes SET Score = 0 WHERE Score != 0;");
|
||||
@@ -1287,7 +1287,7 @@ private:
|
||||
boost::posix_time::ptime tpNext (boost::posix_time::min_date_time);
|
||||
boost::posix_time::ptime tpNow (boost::posix_time::second_clock::universal_time ());
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
Database* db = getApp().getWalletDB ()->getDB ();
|
||||
|
||||
if (db->executeSQL ("SELECT Domain,Next FROM SeedDomains INDEXED BY SeedDomainNext ORDER BY Next LIMIT 1;")
|
||||
@@ -1559,7 +1559,7 @@ private:
|
||||
|
||||
// Remove all current Validator's entries in IpReferrals
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
db->executeSQL (str (boost::format ("DELETE FROM IpReferrals WHERE Validator=%s;") % strEscNodePublic));
|
||||
// XXX Check result.
|
||||
}
|
||||
@@ -1602,7 +1602,7 @@ private:
|
||||
{
|
||||
vstrValues.resize (iValues);
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
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.
|
||||
@@ -1633,7 +1633,7 @@ private:
|
||||
|
||||
// Remove all current Validator's entries in ValidatorReferrals
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
db->executeSQL (str (boost::format ("DELETE FROM ValidatorReferrals WHERE Validator='%s';") % strNodePublic));
|
||||
// XXX Check result.
|
||||
@@ -1704,7 +1704,7 @@ private:
|
||||
std::string strSql = str (boost::format ("INSERT INTO ValidatorReferrals (Validator,Entry,Referral) VALUES %s;")
|
||||
% strJoin (vstrValues.begin (), vstrValues.end (), ","));
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
db->executeSQL (strSql);
|
||||
// XXX Check result.
|
||||
@@ -1756,7 +1756,7 @@ private:
|
||||
std::string strSql = boost::str (boost::format ("SELECT * FROM SeedDomains WHERE Domain=%s;")
|
||||
% sqlEscape (strDomain));
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
bResult = db->executeSQL (strSql) && db->startIterRows ();
|
||||
|
||||
@@ -1830,7 +1830,7 @@ private:
|
||||
% sqlEscape (sdSource.strComment)
|
||||
);
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
if (!db->executeSQL (strSql))
|
||||
{
|
||||
@@ -1857,7 +1857,7 @@ private:
|
||||
std::string strSql = str (boost::format ("SELECT * FROM SeedNodes WHERE PublicKey='%s';")
|
||||
% naNodePublic.humanNodePublic ());
|
||||
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
bResult = db->executeSQL (strSql) && db->startIterRows ();
|
||||
|
||||
@@ -1933,7 +1933,7 @@ private:
|
||||
);
|
||||
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ());
|
||||
auto sl (getApp().getWalletDB ()->lock ());
|
||||
|
||||
if (!db->executeSQL (strSql))
|
||||
{
|
||||
|
||||
@@ -205,7 +205,7 @@ Transaction::pointer Transaction::transactionFromSQL (const std::string& sql)
|
||||
rawTxn.resize (txSize);
|
||||
|
||||
{
|
||||
DeprecatedScopedLock sl (getApp().getTxnDB ()->getDBLock ());
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
|
||||
if (!db->executeSQL (sql, true) || !db->startIterRows ())
|
||||
@@ -350,7 +350,7 @@ Json::Value Transaction::getJson (int options, bool binary) const
|
||||
|
||||
bool Transaction::isHexTxID (const std::string& txid)
|
||||
{
|
||||
if (txid.size () != 64)
|
||||
if (txid.size () != 64)
|
||||
return false;
|
||||
|
||||
auto const ret = std::find_if_not (txid.begin (), txid.end (),
|
||||
|
||||
@@ -52,7 +52,7 @@ JobType Job::getType () const
|
||||
return mType;
|
||||
}
|
||||
|
||||
CancelCallback Job::getCancelCallback () const
|
||||
Job::CancelCallback Job::getCancelCallback () const
|
||||
{
|
||||
bassert (m_cancelCallback);
|
||||
return m_cancelCallback;
|
||||
|
||||
@@ -37,7 +37,7 @@ enum JobType
|
||||
// Job types - the position in this enum indicates the job priority with
|
||||
// earlier jobs having lower priority than later jobs. If you wish to
|
||||
// insert a job at a specific priority, simply add it at the right location.
|
||||
|
||||
|
||||
jtPACK, // Make a fetch pack for a peer
|
||||
jtPUBOLDLEDGER, // An old ledger has been accepted
|
||||
jtVALIDATION_ut, // A validation from an untrusted source
|
||||
@@ -101,6 +101,9 @@ public:
|
||||
|
||||
Job (JobType type, std::uint64_t index);
|
||||
|
||||
/** A callback used to check for canceling a job. */
|
||||
typedef std::function <bool(void)> CancelCallback;
|
||||
|
||||
// VFALCO TODO try to remove the dependency on LoadMonitor.
|
||||
Job (JobType type,
|
||||
std::string const& name,
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
int m_processCount;
|
||||
|
||||
beast::Workers m_workers;
|
||||
CancelCallback m_cancelCallback;
|
||||
Job::CancelCallback m_cancelCallback;
|
||||
|
||||
// statistics tracking
|
||||
beast::insight::Collector::ptr m_collector;
|
||||
@@ -117,10 +117,10 @@ public:
|
||||
|
||||
JobDataMap::iterator iter (m_jobData.find (type));
|
||||
assert (iter != m_jobData.end ());
|
||||
|
||||
|
||||
if (iter == m_jobData.end ())
|
||||
return;
|
||||
|
||||
|
||||
JobTypeData& data (iter->second);
|
||||
|
||||
// FIXME: Workaround incorrect client shutdown ordering
|
||||
@@ -128,17 +128,17 @@ public:
|
||||
assert (type == jtCLIENT || m_workers.getNumberOfThreads () > 0);
|
||||
|
||||
{
|
||||
// If this goes off it means that a child didn't follow
|
||||
// If this goes off it means that a child didn't follow
|
||||
// the Stoppable API rules. A job may only be added if:
|
||||
//
|
||||
// - The JobQueue has NOT stopped
|
||||
// - The JobQueue has NOT stopped
|
||||
// AND
|
||||
// * We are currently processing jobs
|
||||
// OR
|
||||
// * We have have pending jobs
|
||||
// OR
|
||||
// * Not all children are stopped
|
||||
//
|
||||
//
|
||||
ScopedLock lock (m_mutex);
|
||||
assert (! isStopped() && (
|
||||
m_processCount>0 ||
|
||||
@@ -172,8 +172,8 @@ public:
|
||||
|
||||
JobDataMap::const_iterator c = m_jobData.find (t);
|
||||
|
||||
return (c == m_jobData.end ())
|
||||
? 0
|
||||
return (c == m_jobData.end ())
|
||||
? 0
|
||||
: c->second.waiting;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
JobDataMap::const_iterator c = m_jobData.find (t);
|
||||
|
||||
return (c == m_jobData.end ())
|
||||
? 0
|
||||
? 0
|
||||
: (c->second.waiting + c->second.running);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
|
||||
c += 2;
|
||||
|
||||
m_journal.info << "Auto-tuning to " << c <<
|
||||
m_journal.info << "Auto-tuning to " << c <<
|
||||
" validation/transaction/proposal threads";
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public:
|
||||
{
|
||||
JobDataMap::iterator iter (m_jobData.find (t));
|
||||
assert (iter != m_jobData.end ());
|
||||
|
||||
|
||||
if (iter == m_jobData.end ())
|
||||
return std::shared_ptr<LoadEvent> ();
|
||||
|
||||
@@ -259,7 +259,7 @@ public:
|
||||
{
|
||||
JobDataMap::iterator iter (m_jobData.find (t));
|
||||
assert (iter != m_jobData.end ());
|
||||
|
||||
|
||||
if (iter == m_jobData.end ())
|
||||
return LoadEvent::autoptr ();
|
||||
|
||||
@@ -308,7 +308,7 @@ public:
|
||||
JobTypeData& data (x.second);
|
||||
|
||||
LoadMonitor::Stats stats (data.stats ());
|
||||
|
||||
|
||||
int waiting (data.waiting);
|
||||
int running (data.running);
|
||||
|
||||
@@ -350,7 +350,7 @@ private:
|
||||
{
|
||||
JobDataMap::iterator c (m_jobData.find (type));
|
||||
assert (c != m_jobData.end ());
|
||||
|
||||
|
||||
// NIKB: This is ugly and I hate it. We must remove jtINVALID completely
|
||||
// and use something sane.
|
||||
if (c == m_jobData.end ())
|
||||
@@ -396,7 +396,7 @@ private:
|
||||
//
|
||||
// Invariants:
|
||||
// The calling thread owns the JobLock
|
||||
//
|
||||
//
|
||||
void queueJob (Job const& job, ScopedLock const& lock)
|
||||
{
|
||||
JobType const type (job.getType ());
|
||||
|
||||
@@ -47,7 +47,7 @@ Json::Value doTxHistory (RPC::Context& context)
|
||||
|
||||
{
|
||||
Database* db = getApp().getTxnDB ()->getDB ();
|
||||
DeprecatedScopedLock sl (getApp().getTxnDB ()->getDBLock ());
|
||||
auto sl (getApp().getTxnDB ()->lock ());
|
||||
|
||||
SQL_FOREACH (db, sql)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user