|
|
|
@ -555,7 +555,7 @@ void CWallet::MarkDirty()
@@ -555,7 +555,7 @@ void CWallet::MarkDirty()
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet) |
|
|
|
|
bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb) |
|
|
|
|
{ |
|
|
|
|
uint256 hash = wtxIn.GetHash(); |
|
|
|
|
|
|
|
|
@ -576,7 +576,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet)
@@ -576,7 +576,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet)
|
|
|
|
|
if (fInsertedNew) |
|
|
|
|
{ |
|
|
|
|
wtx.nTimeReceived = GetAdjustedTime(); |
|
|
|
|
wtx.nOrderPos = IncOrderPosNext(); |
|
|
|
|
wtx.nOrderPos = IncOrderPosNext(pwalletdb); |
|
|
|
|
|
|
|
|
|
wtx.nTimeSmart = wtx.nTimeReceived; |
|
|
|
|
if (!wtxIn.hashBlock.IsNull()) |
|
|
|
@ -653,7 +653,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet)
@@ -653,7 +653,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet)
|
|
|
|
|
|
|
|
|
|
// Write to disk
|
|
|
|
|
if (fInsertedNew || fUpdated) |
|
|
|
|
if (!wtx.WriteToDisk()) |
|
|
|
|
if (!wtx.WriteToDisk(pwalletdb)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
// Break debit/credit balance caches:
|
|
|
|
@ -689,10 +689,16 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
@@ -689,10 +689,16 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
|
|
|
|
if (fExisted || IsMine(tx) || IsFromMe(tx)) |
|
|
|
|
{ |
|
|
|
|
CWalletTx wtx(this,tx); |
|
|
|
|
|
|
|
|
|
// Get merkle branch if transaction was found in a block
|
|
|
|
|
if (pblock) |
|
|
|
|
wtx.SetMerkleBranch(*pblock); |
|
|
|
|
return AddToWallet(wtx); |
|
|
|
|
|
|
|
|
|
// Do not flush the wallet here for performance reasons
|
|
|
|
|
// this is safe, as in case of a crash, we rescan the necessary blocks on startup through our SetBestChain-mechanism
|
|
|
|
|
CWalletDB walletdb(strWalletFile, "r+", false); |
|
|
|
|
|
|
|
|
|
return AddToWallet(wtx, false, &walletdb); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
@ -916,9 +922,9 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived,
@@ -916,9 +922,9 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived,
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CWalletTx::WriteToDisk() |
|
|
|
|
bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb) |
|
|
|
|
{ |
|
|
|
|
return CWalletDB(pwallet->strWalletFile).WriteTx(GetHash(), *this); |
|
|
|
|
return pwalletdb->WriteTx(GetHash(), *this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1581,14 +1587,14 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
@@ -1581,14 +1587,14 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
|
|
|
|
|
// This is only to keep the database open to defeat the auto-flush for the
|
|
|
|
|
// duration of this scope. This is the only place where this optimization
|
|
|
|
|
// maybe makes sense; please don't do it anywhere else.
|
|
|
|
|
CWalletDB* pwalletdb = fFileBacked ? new CWalletDB(strWalletFile,"r") : NULL; |
|
|
|
|
CWalletDB* pwalletdb = fFileBacked ? new CWalletDB(strWalletFile,"r+") : NULL; |
|
|
|
|
|
|
|
|
|
// Take key pair from key pool so it won't be used again
|
|
|
|
|
reservekey.KeepKey(); |
|
|
|
|
|
|
|
|
|
// Add tx to wallet, because if it has change it's also ours,
|
|
|
|
|
// otherwise just for transaction history.
|
|
|
|
|
AddToWallet(wtxNew); |
|
|
|
|
AddToWallet(wtxNew, false, pwalletdb); |
|
|
|
|
|
|
|
|
|
// Notify that old coins are spent
|
|
|
|
|
set<CWalletTx*> setCoins; |
|
|
|
|