Skip to content

Commit f7baeaf

Browse files
Antoine Riardfurszy
authored andcommitted
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 8d8928e commit f7baeaf

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
@@ -1265,22 +1265,14 @@ void CWallet::TransactionRemovedFromMempool(const CTransactionRef &ptx) {
12651265
void CWallet::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex *pindex, const std::vector<CTransactionRef>& vtxConflicted)
12661266
{
12671267
LOCK2(cs_main, cs_wallet);
1268-
// TODO: Tempoarily ensure that mempool removals are notified before
1269-
// connected transactions. This shouldn't matter, but the abandoned
1270-
// state of transactions in our wallet is currently cleared when we
1271-
// receive another notification and there is a race condition where
1272-
// notification of a connected conflict might cause an outside process
1273-
// to abandon a transaction and then have it inadvertently cleared by
1274-
// the notification that the conflicted transaction was evicted.
12751268

1276-
for (const CTransactionRef& ptx : vtxConflicted) {
1277-
SyncTransaction(ptx, CWalletTx::Status::CONFLICTED, nullptr, -1);
1278-
TransactionRemovedFromMempool(ptx);
1279-
}
12801269
for (size_t i = 0; i < pblock->vtx.size(); i++) {
12811270
SyncTransaction(pblock->vtx[i], CWalletTx::Status::CONFIRMED, pindex, i);
12821271
TransactionRemovedFromMempool(pblock->vtx[i]);
12831272
}
1273+
for (const CTransactionRef& ptx : vtxConflicted) {
1274+
TransactionRemovedFromMempool(ptx);
1275+
}
12841276

12851277
// Sapling: notify about the connected block
12861278
// Get prev block tree anchor

0 commit comments

Comments
 (0)