aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 9b2960f64e..5b32034696 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -767,7 +767,6 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
void CWallet::ReacceptWalletTransactions()
{
- CCoinsDB coinsdb("r");
bool fRepeat = true;
while (fRepeat)
{
@@ -782,7 +781,7 @@ void CWallet::ReacceptWalletTransactions()
CCoins coins;
bool fUpdated = false;
- bool fNotFound = coinsdb.ReadCoins(wtx.GetHash(), coins);
+ bool fNotFound = pcoinsTip->GetCoins(wtx.GetHash(), coins);
if (!fNotFound || wtx.GetDepthInMainChain() > 0)
{
// Update fSpent if a tx got spent somewhere else by a copy of wallet.dat
@@ -808,7 +807,7 @@ void CWallet::ReacceptWalletTransactions()
{
// Re-accept any txes of ours that aren't already in a block
if (!wtx.IsCoinBase())
- wtx.AcceptWalletTransaction(coinsdb, false);
+ wtx.AcceptWalletTransaction(false);
}
}
if (fMissing)
@@ -820,21 +819,22 @@ void CWallet::ReacceptWalletTransactions()
}
}
-void CWalletTx::RelayWalletTransaction(CCoinsDB& coinsdb)
+void CWalletTx::RelayWalletTransaction()
{
+ CCoinsViewCache& coins = *pcoinsTip;
BOOST_FOREACH(const CMerkleTx& tx, vtxPrev)
{
if (!tx.IsCoinBase())
{
uint256 hash = tx.GetHash();
- if (!coinsdb.HaveCoins(hash))
+ if (!coins.HaveCoins(hash))
RelayMessage(CInv(MSG_TX, hash), (CTransaction)tx);
}
}
if (!IsCoinBase())
{
uint256 hash = GetHash();
- if (!coinsdb.HaveCoins(hash))
+ if (!coins.HaveCoins(hash))
{
printf("Relaying wtx %s\n", hash.ToString().substr(0,10).c_str());
RelayMessage(CInv(MSG_TX, hash), (CTransaction)*this);
@@ -842,12 +842,6 @@ void CWalletTx::RelayWalletTransaction(CCoinsDB& coinsdb)
}
}
-void CWalletTx::RelayWalletTransaction()
-{
- CCoinsDB coinsdb("r");
- RelayWalletTransaction(coinsdb);
-}
-
void CWallet::ResendWalletTransactions()
{
// Do this infrequently and randomly to avoid giving away
@@ -868,7 +862,6 @@ void CWallet::ResendWalletTransactions()
// Rebroadcast any of our txes that aren't in a block yet
printf("ResendWalletTransactions()\n");
- CCoinsDB coinsdb("r");
{
LOCK(cs_wallet);
// Sort them in chronological order
@@ -884,7 +877,7 @@ void CWallet::ResendWalletTransactions()
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
{
CWalletTx& wtx = *item.second;
- wtx.RelayWalletTransaction(coinsdb);
+ wtx.RelayWalletTransaction();
}
}
}