Remove pwalletdb parameter from CWallet::AddAccountingEntry

This commit is contained in:
Patrick Strateman 2016-09-09 19:22:59 -07:00
parent d2e678d7d2
commit 02e2a81536
3 changed files with 17 additions and 9 deletions

View file

@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
ae.nTime = 1333333333; ae.nTime = 1333333333;
ae.strOtherAccount = "b"; ae.strOtherAccount = "b";
ae.strComment = ""; ae.strComment = "";
pwalletMain->AddAccountingEntry(ae, walletdb); pwalletMain->AddAccountingEntry(ae);
wtx.mapValue["comment"] = "z"; wtx.mapValue["comment"] = "z";
pwalletMain->AddToWallet(wtx); pwalletMain->AddToWallet(wtx);
@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
ae.nTime = 1333333336; ae.nTime = 1333333336;
ae.strOtherAccount = "c"; ae.strOtherAccount = "c";
pwalletMain->AddAccountingEntry(ae, walletdb); pwalletMain->AddAccountingEntry(ae);
GetResults(walletdb, results); GetResults(walletdb, results);
@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
ae.nTime = 1333333330; ae.nTime = 1333333330;
ae.strOtherAccount = "d"; ae.strOtherAccount = "d";
ae.nOrderPos = pwalletMain->IncOrderPosNext(); ae.nOrderPos = pwalletMain->IncOrderPosNext();
pwalletMain->AddAccountingEntry(ae, walletdb); pwalletMain->AddAccountingEntry(ae);
GetResults(walletdb, results); GetResults(walletdb, results);
@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
ae.nTime = 1333333334; ae.nTime = 1333333334;
ae.strOtherAccount = "e"; ae.strOtherAccount = "e";
ae.nOrderPos = -1; ae.nOrderPos = -1;
pwalletMain->AddAccountingEntry(ae, walletdb); pwalletMain->AddAccountingEntry(ae);
GetResults(walletdb, results); GetResults(walletdb, results);

View file

@ -683,7 +683,7 @@ bool CWallet::AccountMove(std::string strFrom, std::string strTo, CAmount nAmoun
debit.nTime = nNow; debit.nTime = nNow;
debit.strOtherAccount = strTo; debit.strOtherAccount = strTo;
debit.strComment = strComment; debit.strComment = strComment;
AddAccountingEntry(debit, walletdb); AddAccountingEntry(debit, &walletdb);
// Credit // Credit
CAccountingEntry credit; CAccountingEntry credit;
@ -693,7 +693,7 @@ bool CWallet::AccountMove(std::string strFrom, std::string strTo, CAmount nAmoun
credit.nTime = nNow; credit.nTime = nNow;
credit.strOtherAccount = strFrom; credit.strOtherAccount = strFrom;
credit.strComment = strComment; credit.strComment = strComment;
AddAccountingEntry(credit, walletdb); AddAccountingEntry(credit, &walletdb);
if (!walletdb.TxnCommit()) if (!walletdb.TxnCommit())
return false; return false;
@ -2512,9 +2512,16 @@ void CWallet::ListAccountCreditDebit(const std::string& strAccount, std::list<CA
return walletdb.ListAccountCreditDebit(strAccount, entries); return walletdb.ListAccountCreditDebit(strAccount, entries);
} }
bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB & pwalletdb) bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry)
{ {
if (!pwalletdb.WriteAccountingEntry_Backend(acentry)) CWalletDB walletdb(strWalletFile);
return AddAccountingEntry(acentry, &walletdb);
}
bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB *pwalletdb)
{
if (!pwalletdb->WriteAccountingEntry_Backend(acentry))
return false; return false;
laccentries.push_back(acentry); laccentries.push_back(acentry);

View file

@ -777,7 +777,8 @@ public:
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CConnman* connman); bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CConnman* connman);
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& entries); void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& entries);
bool AddAccountingEntry(const CAccountingEntry&, CWalletDB & pwalletdb); bool AddAccountingEntry(const CAccountingEntry&);
bool AddAccountingEntry(const CAccountingEntry&, CWalletDB *pwalletdb);
static CFeeRate minTxFee; static CFeeRate minTxFee;
static CFeeRate fallbackFee; static CFeeRate fallbackFee;