Skip to content

Commit 69b3330

Browse files
committed
GUI: txmodel, do not lock cs_wallet if no wtx status update is needed.
1 parent b4ab286 commit 69b3330

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/qt/transactiontablemodel.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,25 +303,21 @@ class TransactionTablePriv
303303
{
304304
if (idx >= 0 && idx < cachedWallet.size()) {
305305
TransactionRecord* rec = &cachedWallet[idx];
306-
307-
// Get required locks upfront. This avoids the GUI from getting
308-
// stuck if the core is holding the locks for a longer time - for
309-
// example, during a wallet rescan.
310-
//
311-
// If a status update is needed (blocks came in since last check),
312-
// update the status of this transaction from the wallet. Otherwise,
313-
// simply re-use the cached status.
314-
TRY_LOCK(wallet->cs_wallet, lockWallet);
315-
if (lockWallet && rec->statusUpdateNeeded(cur_block_num)) {
316-
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
317-
318-
if (mi != wallet->mapWallet.end()) {
319-
rec->updateStatus(mi->second, cur_block_num);
306+
if (!cur_block_hash.IsNull() && rec->statusUpdateNeeded(cur_block_num)) {
307+
// If a status update is needed (blocks came in since last check),
308+
// update the status of this transaction from the wallet. Otherwise,
309+
// simply re-use the cached status.
310+
TRY_LOCK(wallet->cs_wallet, lockWallet);
311+
if (lockWallet) {
312+
auto mi = wallet->mapWallet.find(rec->hash);
313+
if (mi != wallet->mapWallet.end()) {
314+
rec->updateStatus(mi->second, cur_block_num);
315+
}
320316
}
321317
}
322318
return rec;
323319
}
324-
return 0;
320+
return nullptr;
325321
}
326322
};
327323

0 commit comments

Comments
 (0)