Skip to content

Commit

Permalink
Merge 4946400 into merged_master (Bitcoin PR bitcoin-core/gui#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Nov 26, 2020
2 parents f735896 + 4946400 commit e9e6902
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ void TransactionRecord::updateStatus(const interfaces::WalletTxStatus& wtx, cons

bool TransactionRecord::statusUpdateNeeded(const uint256& block_hash) const
{
assert(!block_hash.IsNull());
return status.m_cur_block_hash != block_hash || status.needsUpdate;
}

Expand Down
4 changes: 2 additions & 2 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class TransactionTablePriv
interfaces::WalletTxStatus wtx;
int numBlocks;
int64_t block_time;
if (rec->statusUpdateNeeded(cur_block_hash) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
if (!cur_block_hash.IsNull() && rec->statusUpdateNeeded(cur_block_hash) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
rec->updateStatus(wtx, cur_block_hash, numBlocks, block_time);
}
return rec;
Expand Down Expand Up @@ -669,7 +669,7 @@ QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientat
QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(parent);
TransactionRecord* data = priv->index(walletModel->wallet(), walletModel->clientModel().getBestBlockHash(), row);
TransactionRecord* data = priv->index(walletModel->wallet(), walletModel->getLastBlockProcessed(), row);
if(data)
{
return createIndex(row, column, data);
Expand Down
7 changes: 6 additions & 1 deletion src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void WalletModel::pollBalanceChanged()
{
// Avoid recomputing wallet balances unless a TransactionChanged or
// BlockTip notification was received.
if (!fForceCheckBalanceChanged && m_cached_last_update_tip == m_client_model->getBestBlockHash()) return;
if (!fForceCheckBalanceChanged && m_cached_last_update_tip == getLastBlockProcessed()) return;

// Try to get balances and return early if locks can't be acquired. This
// avoids the GUI from getting stuck on periodical polls if the core is
Expand Down Expand Up @@ -623,3 +623,8 @@ void WalletModel::refresh(bool pk_hash_only)
{
addressTableModel = new AddressTableModel(this, pk_hash_only);
}

uint256 WalletModel::getLastBlockProcessed() const
{
return m_client_model ? m_client_model->getBestBlockHash() : uint256{};
}
3 changes: 3 additions & 0 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ class WalletModel : public QObject
AddressTableModel* getAddressTableModel() const { return addressTableModel; }

void refresh(bool pk_hash_only = false);

uint256 getLastBlockProcessed() const;

private:
std::unique_ptr<interfaces::Wallet> m_wallet;
std::unique_ptr<interfaces::Handler> m_handler_unload;
Expand Down

0 comments on commit e9e6902

Please sign in to comment.