From 4c6e22953ef8ae0764576993088ec83d729d18f8 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 28 Jun 2011 23:45:22 +0200 Subject: [PATCH] Make CWalletTx::pwallet private --- src/db.cpp | 2 +- src/wallet.cpp | 6 +++--- src/wallet.h | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 9ac93b3506..9b29e799e0 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -810,7 +810,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet) ssKey >> hash; CWalletTx& wtx = pwallet->mapWallet[hash]; ssValue >> wtx; - wtx.pwallet = pwallet; + wtx.BindWallet(pwallet); if (wtx.GetHash() != hash) printf("Error in wallet.dat, hash mismatch\n"); diff --git a/src/wallet.cpp b/src/wallet.cpp index 28babdb3e2..c451186d96 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -232,7 +232,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) // Inserts only if not already there, returns tx inserted or tx found pair::iterator, bool> ret = mapWallet.insert(make_pair(hash, wtxIn)); CWalletTx& wtx = (*ret.first).second; - wtx.pwallet = this; + wtx.BindWallet(this); bool fInsertedNew = ret.second; if (fInsertedNew) wtx.nTimeReceived = GetAdjustedTime(); @@ -924,7 +924,7 @@ bool CWallet::CreateTransaction(const vector >& vecSend, CW if (vecSend.empty() || nValue < 0) return false; - wtxNew.pwallet = this; + wtxNew.BindWallet(this); CRITICAL_BLOCK(cs_main) CRITICAL_BLOCK(cs_wallet) @@ -1062,7 +1062,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) BOOST_FOREACH(const CTxIn& txin, wtxNew.vin) { CWalletTx &coin = mapWallet[txin.prevout.hash]; - coin.pwallet = this; + coin.BindWallet(this); coin.MarkSpent(txin.prevout.n); coin.WriteToDisk(); vWalletUpdated.push_back(coin.GetHash()); diff --git a/src/wallet.h b/src/wallet.h index ca7cf67317..e1c39a6f39 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -243,9 +243,10 @@ public: // class CWalletTx : public CMerkleTx { -public: +private: const CWallet* pwallet; +public: std::vector vtxPrev; std::map mapValue; std::vector > vOrderForm; @@ -389,6 +390,12 @@ public: fChangeCached = false; } + void BindWallet(CWallet *pwalletIn) + { + pwallet = pwalletIn; + MarkDirty(); + } + void MarkSpent(unsigned int nOut) { if (nOut >= vout.size())