mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Use the current snapshot to get immutable ledger optimizations.
This commit is contained in:
@@ -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);
|
||||||
|
|
||||||
@@ -1860,6 +1862,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();
|
||||||
@@ -1869,15 +1874,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);
|
||||||
|
|
||||||
@@ -2620,7 +2616,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