aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2014-02-28 15:16:25 -0500
committerGavin Andresen <gavinandresen@gmail.com>2014-02-28 15:16:25 -0500
commitf60e49d49c72908356d70d05ae30c6e63be2192d (patch)
tree3fdc2c60417664b6b13005b06085d99472cd250b /src/main.cpp
parent68c97fe11064fbcce891a88c7144b9cf30f2d23e (diff)
parent93a18a3650292afbb441a47d1fa1b94aeb0164e3 (diff)
downloadbitcoin-f60e49d49c72908356d70d05ae30c6e63be2192d.tar.xz
Merge pull request #3694 from gavinandresen/vfspent
Remove CWalletTx::vfSpent
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 8a5b659e7c..7afaa9e7e2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1866,17 +1866,23 @@ bool static DisconnectTip(CValidationState &state) {
// Write the chain state to disk, if necessary.
if (!WriteChainState(state))
return false;
- // Ressurect mempool transactions from the disconnected block.
+ // Resurrect mempool transactions from the disconnected block.
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
// ignore validation errors in resurrected transactions
+ list<CTransaction> removed;
CValidationState stateDummy;
if (!tx.IsCoinBase())
if (!AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
- mempool.remove(tx, true);
+ mempool.remove(tx, removed, true);
}
mempool.check(pcoinsTip);
// Update chainActive and related variables.
UpdateTip(pindexDelete->pprev);
+ // Let wallets know transactions went from 1-confirmed to
+ // 0-confirmed or conflicted:
+ BOOST_FOREACH(const CTransaction &tx, block.vtx) {
+ SyncWithWallets(tx.GetHash(), tx, NULL);
+ }
return true;
}
@@ -1907,13 +1913,24 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew) {
if (!WriteChainState(state))
return false;
// Remove conflicting transactions from the mempool.
+ list<CTransaction> txConflicted;
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
- mempool.remove(tx);
- mempool.removeConflicts(tx);
+ list<CTransaction> unused;
+ mempool.remove(tx, unused);
+ mempool.removeConflicts(tx, txConflicted);
}
mempool.check(pcoinsTip);
// Update chainActive & related variables.
UpdateTip(pindexNew);
+ // Tell wallet about transactions that went from mempool
+ // to conflicted:
+ BOOST_FOREACH(const CTransaction &tx, txConflicted) {
+ SyncWithWallets(tx.GetHash(), tx, NULL);
+ }
+ // ... and about transactions that got confirmed:
+ BOOST_FOREACH(const CTransaction &tx, block.vtx) {
+ SyncWithWallets(tx.GetHash(), tx, &block);
+ }
return true;
}