@@ -341,7 +341,7 @@ void MempoolStats::drawWalletTxIndicators()
341341 if (!m_clientmodel)
342342 return ;
343343
344- std::set <interfaces::WalletTx> wallet_transactions_copy;
344+ QList <interfaces::WalletTx> wallet_transactions_copy;
345345 {
346346 QMutexLocker locker (&m_wallet_tx_mutex);
347347 wallet_transactions_copy = m_wallet_transactions;
@@ -363,49 +363,33 @@ void MempoolStats::drawWalletTxIndicators()
363363
364364 for (const interfaces::WalletTx& wtx : wallet_transactions_copy) {
365365 if (!wtx.tx ) continue ;
366- bool in_mempool = false ;
367- CAmount net_amount = 0 ;
368-
369- for (std::unique_ptr<interfaces::Wallet>& wallet_ptr : m_clientmodel->node ().walletLoader ().getWallets ()) {
370- if (!wallet_ptr) continue ;
371- interfaces::WalletTxStatus tx_status;
372- int num_blocks;
373- int64_t block_time;
374-
375- if (wallet_ptr->tryGetTxStatus (wtx.tx ->GetHash (), tx_status, num_blocks, block_time)) {
376- if (tx_status.depth_in_main_chain == 0 && !tx_status.is_abandoned ) {
377- in_mempool = true ;
378- net_amount = wtx.credit - wtx.debit ;
379- break ; // Found status for this transaction, no need to check other wallets
380- }
381- }
382- }
366+ // Transactions in m_wallet_transactions are already filtered to be in mempool
367+ // No need to check status again here.
368+ CAmount net_amount = wtx.credit - wtx.debit ;
383369
384370 if (MEMPOOL_GRAPH_LOGGING) {
385- LogPrintf (" drawWalletTxIndicators: tx %s, in_mempool: %s, net_amount: %s\n " , wtx.tx ->GetHash ().ToString (), in_mempool , net_amount);
371+ LogPrintf (" drawWalletTxIndicators: tx %s, net_amount: %s\n " , wtx.tx ->GetHash ().ToString (), net_amount);
386372 }
387373
388- if (in_mempool) {
389- QGraphicsTextItem *sign_item = nullptr ;
390- QColor sign_color;
391-
392- if (net_amount > 0 ) { // Receive transaction
393- gridFont.setPointSize (36 );
394- sign_item = m_scene->addText (" +" , gridFont);
395- sign_color = QColor (0 , 255 , 0 ); // Green
396- } else if (net_amount < 0 ) { // Send transaction
397- gridFont.setPointSize (48 );
398- sign_item = m_scene->addText (" -" , gridFont);
399- sign_color = QColor (255 , 0 , 0 ); // Red
400- }
374+ QGraphicsTextItem *sign_item = nullptr ;
375+ QColor sign_color;
376+
377+ if (net_amount > 0 ) { // Receive transaction
378+ gridFont.setPointSize (36 );
379+ sign_item = m_scene->addText (" +" , gridFont);
380+ sign_color = QColor (0 , 255 , 0 ); // Green
381+ } else if (net_amount < 0 ) { // Send transaction
382+ gridFont.setPointSize (48 );
383+ sign_item = m_scene->addText (" -" , gridFont);
384+ sign_color = QColor (255 , 0 , 0 ); // Red
385+ }
401386
402- if (sign_item) {
403- sign_item->setDefaultTextColor (sign_color);
404- sign_item->setPos (indicator_x, indicator_y);
405- sign_item->setToolTip (QString::fromStdString (wtx.tx ->GetHash ().ToString ()));
406- m_wallet_indicator_items.append (sign_item); // Store the item
407- indicator_y += y_offset; // Move down for the next indicator
408- }
387+ if (sign_item) {
388+ sign_item->setDefaultTextColor (sign_color);
389+ sign_item->setPos (indicator_x, indicator_y);
390+ sign_item->setToolTip (QString::fromStdString (wtx.tx ->GetHash ().ToString ()));
391+ m_wallet_indicator_items.append (sign_item); // Store the item
392+ indicator_y += y_offset; // Move down for the next indicator
409393 }
410394 }
411395 }
@@ -431,18 +415,11 @@ void MempoolStats::onWalletTxChanged()
431415 {
432416 QMutexLocker locker (&m_wallet_tx_mutex);
433417 if (m_clientmodel) {
434- m_clientmodel->m_wallet_transactions .clear (); // Clear ClientModel's transactions
435- for (std::unique_ptr<interfaces::Wallet>& wallet_ptr : m_clientmodel->node ().walletLoader ().getWallets ()) {
436- if (!wallet_ptr) continue ;
437- for (const interfaces::WalletTx& wtx : wallet_ptr->getWalletTxs ()) {
438- m_clientmodel->m_wallet_transactions .insert (wtx); // Populate ClientModel's transactions
439- }
440- }
441- m_wallet_transactions = m_clientmodel->m_wallet_transactions ; // Keep MempoolStats's local copy in sync for indicators
418+ // ClientModel's m_wallet_transactions is already updated and filtered by ClientModel itself.
419+ // We just need to keep MempoolStats's local copy in sync.
420+ m_wallet_transactions = m_clientmodel->m_wallet_transactions ;
442421 }
443422 }
444423 QMetaObject::invokeMethod (this , " drawChart" , Qt::QueuedConnection);
445- if (m_clientmodel) {
446- Q_EMIT m_clientmodel->walletTxChanged (); // Emit ClientModel's signal
447- }
424+ // No need to emit ClientModel's signal here, it's already emitted by ClientModel itself.
448425}
0 commit comments