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