Optimisation: Store transaction list order in memory rather than compute it every need
Huge performance improvement (450%) for zapwallettxes
This commit is contained in:
@@ -835,7 +835,7 @@ UniValue movecmd(const UniValue& params, bool fHelp)
|
||||
debit.nTime = nNow;
|
||||
debit.strOtherAccount = strTo;
|
||||
debit.strComment = strComment;
|
||||
walletdb.WriteAccountingEntry(debit);
|
||||
pwalletMain->AddAccountingEntry(debit, walletdb);
|
||||
|
||||
// Credit
|
||||
CAccountingEntry credit;
|
||||
@@ -845,7 +845,7 @@ UniValue movecmd(const UniValue& params, bool fHelp)
|
||||
credit.nTime = nNow;
|
||||
credit.strOtherAccount = strFrom;
|
||||
credit.strComment = strComment;
|
||||
walletdb.WriteAccountingEntry(credit);
|
||||
pwalletMain->AddAccountingEntry(credit, walletdb);
|
||||
|
||||
if (!walletdb.TxnCommit())
|
||||
throw JSONRPCError(RPC_DATABASE_ERROR, "database error");
|
||||
@@ -1470,11 +1470,10 @@ UniValue listtransactions(const UniValue& params, bool fHelp)
|
||||
|
||||
UniValue ret(UniValue::VARR);
|
||||
|
||||
std::list<CAccountingEntry> acentries;
|
||||
CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount);
|
||||
const CWallet::TxItems & txOrdered = pwalletMain->wtxOrdered;
|
||||
|
||||
// iterate backwards until we have nCount items to return:
|
||||
for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
|
||||
for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
|
||||
{
|
||||
CWalletTx *const pwtx = (*it).second.first;
|
||||
if (pwtx != 0)
|
||||
@@ -1579,8 +1578,7 @@ UniValue listaccounts(const UniValue& params, bool fHelp)
|
||||
}
|
||||
}
|
||||
|
||||
list<CAccountingEntry> acentries;
|
||||
CWalletDB(pwalletMain->strWalletFile).ListAccountCreditDebit("*", acentries);
|
||||
const list<CAccountingEntry> & acentries = pwalletMain->laccentries;
|
||||
BOOST_FOREACH(const CAccountingEntry& entry, acentries)
|
||||
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user