mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
[rpc] Reduce scope of cs_main and cs_wallet locks in listtransactions
This commit is contained in:
parent
41363fe11d
commit
c409b1adac
1 changed files with 16 additions and 13 deletions
|
@ -1794,8 +1794,6 @@ UniValue listtransactions(const JSONRPCRequest& request)
|
||||||
// the user could have gotten from another RPC command prior to now
|
// the user could have gotten from another RPC command prior to now
|
||||||
pwallet->BlockUntilSyncedToCurrentChain();
|
pwallet->BlockUntilSyncedToCurrentChain();
|
||||||
|
|
||||||
LOCK2(cs_main, pwallet->cs_wallet);
|
|
||||||
|
|
||||||
std::string strAccount = "*";
|
std::string strAccount = "*";
|
||||||
if (!request.params[0].isNull())
|
if (!request.params[0].isNull())
|
||||||
strAccount = request.params[0].get_str();
|
strAccount = request.params[0].get_str();
|
||||||
|
@ -1817,20 +1815,25 @@ UniValue listtransactions(const JSONRPCRequest& request)
|
||||||
|
|
||||||
UniValue ret(UniValue::VARR);
|
UniValue ret(UniValue::VARR);
|
||||||
|
|
||||||
const CWallet::TxItems & txOrdered = pwallet->wtxOrdered;
|
|
||||||
|
|
||||||
// iterate backwards until we have nCount items to return:
|
|
||||||
for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
|
|
||||||
{
|
{
|
||||||
CWalletTx *const pwtx = (*it).second.first;
|
LOCK2(cs_main, pwallet->cs_wallet);
|
||||||
if (pwtx != nullptr)
|
|
||||||
ListTransactions(pwallet, *pwtx, strAccount, 0, true, ret, filter);
|
|
||||||
CAccountingEntry *const pacentry = (*it).second.second;
|
|
||||||
if (pacentry != nullptr)
|
|
||||||
AcentryToJSON(*pacentry, strAccount, ret);
|
|
||||||
|
|
||||||
if ((int)ret.size() >= (nCount+nFrom)) break;
|
const CWallet::TxItems & txOrdered = pwallet->wtxOrdered;
|
||||||
|
|
||||||
|
// iterate backwards until we have nCount items to return:
|
||||||
|
for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
|
||||||
|
{
|
||||||
|
CWalletTx *const pwtx = (*it).second.first;
|
||||||
|
if (pwtx != nullptr)
|
||||||
|
ListTransactions(pwallet, *pwtx, strAccount, 0, true, ret, filter);
|
||||||
|
CAccountingEntry *const pacentry = (*it).second.second;
|
||||||
|
if (pacentry != nullptr)
|
||||||
|
AcentryToJSON(*pacentry, strAccount, ret);
|
||||||
|
|
||||||
|
if ((int)ret.size() >= (nCount+nFrom)) break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ret is newest to oldest
|
// ret is newest to oldest
|
||||||
|
|
||||||
if (nFrom > (int)ret.size())
|
if (nFrom > (int)ret.size())
|
||||||
|
|
Loading…
Reference in a new issue