Skip to content

Commit 7e89994

Browse files
author
Antoine Riard
committed
Remove SyncTransaction for conflicted txn in CWallet::BlockConnected
We shouldn't rely on this sync call to get an accurate view of txn state, if a tx conflicts with one in mapTx we are going to update our wallet dependencies in AddToWalletIfInvolvingMe while conflicting txn get connected. If it doesn't conflict with one of our dependencies we are not going to track it anyway. This is a cleanup, as this SyncTransaction is redundant with the following one for confirmation which is triggering the MarkConflicted logic. We keep the loop because set of conflicted txn isn't same as txn included in block.
1 parent a31be09 commit 7e89994

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/wallet/wallet.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,22 +1410,14 @@ void CWallet::BlockConnected(const CBlock& block, const std::vector<CTransaction
14101410
const uint256& block_hash = block.GetHash();
14111411
auto locked_chain = chain().lock();
14121412
LOCK(cs_wallet);
1413-
// TODO: Temporarily ensure that mempool removals are notified before
1414-
// connected transactions. This shouldn't matter, but the abandoned
1415-
// state of transactions in our wallet is currently cleared when we
1416-
// receive another notification and there is a race condition where
1417-
// notification of a connected conflict might cause an outside process
1418-
// to abandon a transaction and then have it inadvertently cleared by
1419-
// the notification that the conflicted transaction was evicted.
14201413

1421-
for (const CTransactionRef& ptx : vtxConflicted) {
1422-
SyncTransaction(ptx, CWalletTx::Status::CONFLICTED, {} /* block hash */, 0 /* position in block */);
1423-
TransactionRemovedFromMempool(ptx);
1424-
}
14251414
for (size_t i = 0; i < block.vtx.size(); i++) {
14261415
SyncTransaction(block.vtx[i], CWalletTx::Status::CONFIRMED, block_hash, i);
14271416
TransactionRemovedFromMempool(block.vtx[i]);
14281417
}
1418+
for (const CTransactionRef& ptx : vtxConflicted) {
1419+
TransactionRemovedFromMempool(ptx);
1420+
}
14291421

14301422
m_last_block_processed = block_hash;
14311423
}

0 commit comments

Comments
 (0)