diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index de444d4da..37ca82103 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -177,8 +177,7 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit) return rpcError(rpcINVALID_PARAMS); } - Ledger::pointer lSnapshot = boost::make_shared( - 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); @@ -1860,6 +1862,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(); @@ -1869,15 +1874,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(*lpLedger, false); - assert(lpLedger->isImmutable()); - } - - if (lpLedger->isImmutable()) - MasterLockHolder.unlock(); - Json::Value ret(Json::objectValue); lpLedger->addJson(ret, iOptions); @@ -2620,7 +2616,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;