[rpc] Reduce scope of cs_main and cs_wallet locks in listtransactions

This commit is contained in:
João Barbosa 2018-02-02 01:57:29 +00:00
parent 41363fe11d
commit c409b1adac

View file

@ -1794,8 +1794,6 @@ UniValue listtransactions(const JSONRPCRequest& request)
// the user could have gotten from another RPC command prior to now
pwallet->BlockUntilSyncedToCurrentChain();
LOCK2(cs_main, pwallet->cs_wallet);
std::string strAccount = "*";
if (!request.params[0].isNull())
strAccount = request.params[0].get_str();
@ -1817,6 +1815,9 @@ UniValue listtransactions(const JSONRPCRequest& request)
UniValue ret(UniValue::VARR);
{
LOCK2(cs_main, pwallet->cs_wallet);
const CWallet::TxItems & txOrdered = pwallet->wtxOrdered;
// iterate backwards until we have nCount items to return:
@ -1831,6 +1832,8 @@ UniValue listtransactions(const JSONRPCRequest& request)
if ((int)ret.size() >= (nCount+nFrom)) break;
}
}
// ret is newest to oldest
if (nFrom > (int)ret.size())