mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Merge branch 'cache_snapshot' into develop
This commit is contained in:
@@ -256,6 +256,7 @@ bool Ledger::addTransaction(const uint256& txID, const Serializer& txn)
|
||||
cLog(lsWARNING) << "Attempt to add transaction to ledger that already had it";
|
||||
return false;
|
||||
}
|
||||
mValidHash = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -270,6 +271,7 @@ bool Ledger::addTransaction(const uint256& txID, const Serializer& txn, const Se
|
||||
cLog(lsFATAL) << "Attempt to add transaction+MD to ledger that already had it";
|
||||
return false;
|
||||
}
|
||||
mValidHash = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,14 @@ uint32 LedgerMaster::getCurrentLedgerIndex()
|
||||
return mCurrentLedger->getLedgerSeq();
|
||||
}
|
||||
|
||||
Ledger::ref LedgerMaster::getCurrentSnapshot()
|
||||
{
|
||||
if (!mCurrentSnapshot || (mCurrentSnapshot->getHash() != mCurrentLedger->getHash()))
|
||||
mCurrentSnapshot = boost::make_shared<Ledger>(boost::ref(*mCurrentLedger), false);
|
||||
assert(mCurrentSnapshot->isImmutable());
|
||||
return mCurrentSnapshot;
|
||||
}
|
||||
|
||||
void LedgerMaster::addHeldTransaction(Transaction::ref transaction)
|
||||
{ // returns true if transaction was added
|
||||
boost::recursive_mutex::scoped_lock ml(mLock);
|
||||
|
||||
@@ -26,6 +26,7 @@ protected:
|
||||
TransactionEngine mEngine;
|
||||
|
||||
Ledger::pointer mCurrentLedger; // The ledger we are currently processiong
|
||||
Ledger::pointer mCurrentSnapshot; // Snapshot of the current ledger
|
||||
Ledger::pointer mFinalizedLedger; // The ledger that most recently closed
|
||||
Ledger::pointer mValidLedger; // The highest-sequence ledger we have fully accepted
|
||||
Ledger::pointer mPubLedger; // The last ledger we have published
|
||||
@@ -74,6 +75,9 @@ public:
|
||||
// The current ledger is the ledger we believe new transactions should go in
|
||||
Ledger::ref getCurrentLedger() { return mCurrentLedger; }
|
||||
|
||||
// An immutable snapshot of the current ledger
|
||||
Ledger::ref getCurrentSnapshot();
|
||||
|
||||
// The finalized ledger is the last closed/accepted ledger
|
||||
Ledger::ref getClosedLedger() { return mFinalizedLedger; }
|
||||
|
||||
|
||||
@@ -183,6 +183,7 @@ public:
|
||||
Ledger::ref getClosedLedger() { return mLedgerMaster->getClosedLedger(); }
|
||||
Ledger::ref getValidatedLedger() { return mLedgerMaster->getValidatedLedger(); }
|
||||
Ledger::ref getCurrentLedger() { return mLedgerMaster->getCurrentLedger(); }
|
||||
Ledger::ref getCurrentSnapshot() { return mLedgerMaster->getCurrentSnapshot(); }
|
||||
Ledger::pointer getLedgerByHash(const uint256& hash) { return mLedgerMaster->getLedgerByHash(hash); }
|
||||
Ledger::pointer getLedgerBySeq(const uint32 seq);
|
||||
void missingNodeInLedger(const uint32 seq);
|
||||
|
||||
@@ -177,8 +177,7 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit)
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
Ledger::pointer lSnapshot = boost::make_shared<Ledger>(
|
||||
boost::ref(*mNetOps->getCurrentLedger()), false);
|
||||
Ledger::pointer lSnapshot = mNetOps->getCurrentSnapshot();
|
||||
{
|
||||
ScopedUnlock su(theApp->getMasterLock());
|
||||
bool bValid;
|
||||
@@ -1031,6 +1030,9 @@ Json::Value RPCHandler::doAccountLines(Json::Value jvRequest, int& cost, ScopedL
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (lpLedger->isImmutable())
|
||||
MasterLockHolder.unlock();
|
||||
|
||||
if (!jvRequest.isMember("account"))
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
@@ -1065,9 +1067,6 @@ Json::Value RPCHandler::doAccountLines(Json::Value jvRequest, int& cost, ScopedL
|
||||
|
||||
AccountState::pointer as = mNetOps->getAccountState(lpLedger, raAccount);
|
||||
|
||||
if (lpLedger->isImmutable())
|
||||
MasterLockHolder.unlock();
|
||||
|
||||
if (as)
|
||||
{
|
||||
jvResult["account"] = raAccount.humanAccountID();
|
||||
@@ -1124,6 +1123,9 @@ Json::Value RPCHandler::doAccountOffers(Json::Value jvRequest, int& cost, Scoped
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (lpLedger->isImmutable())
|
||||
MasterLockHolder.unlock();
|
||||
|
||||
if (!jvRequest.isMember("account"))
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
@@ -1852,6 +1854,9 @@ Json::Value RPCHandler::doLedger(Json::Value jvRequest, int& cost, ScopedLock& M
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (lpLedger->isImmutable())
|
||||
MasterLockHolder.unlock();
|
||||
|
||||
bool bFull = jvRequest.isMember("full") && jvRequest["full"].asBool();
|
||||
bool bTransactions = jvRequest.isMember("transactions") && jvRequest["transactions"].asBool();
|
||||
bool bAccounts = jvRequest.isMember("accounts") && jvRequest["accounts"].asBool();
|
||||
@@ -1861,15 +1866,6 @@ Json::Value RPCHandler::doLedger(Json::Value jvRequest, int& cost, ScopedLock& M
|
||||
| (bTransactions ? LEDGER_JSON_DUMP_TXRP : 0)
|
||||
| (bAccounts ? LEDGER_JSON_DUMP_STATE : 0);
|
||||
|
||||
if ((bFull || bAccounts) && !lpLedger->isImmutable())
|
||||
{ // For full or accounts, it's cheaper to snapshot
|
||||
lpLedger = boost::make_shared<Ledger>(*lpLedger, false);
|
||||
assert(lpLedger->isImmutable());
|
||||
}
|
||||
|
||||
if (lpLedger->isImmutable())
|
||||
MasterLockHolder.unlock();
|
||||
|
||||
Json::Value ret(Json::objectValue);
|
||||
lpLedger->addJson(ret, iOptions);
|
||||
|
||||
@@ -2612,7 +2608,7 @@ Json::Value RPCHandler::lookupLedger(Json::Value jvRequest, Ledger::pointer& lpL
|
||||
|
||||
switch (iLedgerIndex) {
|
||||
case LEDGER_CURRENT:
|
||||
lpLedger = mNetOps->getCurrentLedger();
|
||||
lpLedger = mNetOps->getCurrentSnapshot();
|
||||
iLedgerIndex = lpLedger->getLedgerSeq();
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user