Changeset View
Changeset View
Standalone View
Standalone View
src/qt/transactiontablemodel.cpp
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | void updateWallet(interfaces::Wallet &wallet, const TxId &txid, int status, | ||||
// transactions. | // transactions. | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
int size() { return cachedWallet.size(); } | int size() { return cachedWallet.size(); } | ||||
TransactionRecord *index(interfaces::Wallet &wallet, | TransactionRecord *index(interfaces::Wallet &wallet, | ||||
const int cur_num_blocks, const int idx) { | const BlockHash &cur_block_hash, const int idx) { | ||||
if (idx >= 0 && idx < cachedWallet.size()) { | if (idx >= 0 && idx < cachedWallet.size()) { | ||||
TransactionRecord *rec = &cachedWallet[idx]; | TransactionRecord *rec = &cachedWallet[idx]; | ||||
// Get required locks upfront. This avoids the GUI from getting | // Get required locks upfront. This avoids the GUI from getting | ||||
// stuck if the core is holding the locks for a longer time - for | // stuck if the core is holding the locks for a longer time - for | ||||
// example, during a wallet rescan. | // example, during a wallet rescan. | ||||
// | // | ||||
// If a status update is needed (blocks came in since last check), | // If a status update is needed (blocks came in since last check), | ||||
// update the status of this transaction from the wallet. Otherwise, | // update the status of this transaction from the wallet. Otherwise, | ||||
// simply re-use the cached status. | // simply re-use the cached status. | ||||
interfaces::WalletTxStatus wtx; | interfaces::WalletTxStatus wtx; | ||||
int numBlocks; | int numBlocks; | ||||
int64_t block_time; | int64_t block_time; | ||||
if (rec->statusUpdateNeeded(cur_num_blocks) && | if (rec->statusUpdateNeeded(cur_block_hash) && | ||||
wallet.tryGetTxStatus(rec->txid, wtx, numBlocks, block_time)) { | wallet.tryGetTxStatus(rec->txid, wtx, numBlocks, block_time)) { | ||||
rec->updateStatus(wtx, numBlocks, block_time); | rec->updateStatus(wtx, cur_block_hash, numBlocks, block_time); | ||||
} | } | ||||
return rec; | return rec; | ||||
} | } | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
QString describe(interfaces::Node &node, interfaces::Wallet &wallet, | QString describe(interfaces::Node &node, interfaces::Wallet &wallet, | ||||
TransactionRecord *rec, int unit) { | TransactionRecord *rec, int unit) { | ||||
▲ Show 20 Lines • Show All 467 Lines • ▼ Show 20 Lines | QVariant TransactionTableModel::headerData(int section, | ||||
} | } | ||||
return QVariant(); | return QVariant(); | ||||
} | } | ||||
QModelIndex TransactionTableModel::index(int row, int column, | QModelIndex TransactionTableModel::index(int row, int column, | ||||
const QModelIndex &parent) const { | const QModelIndex &parent) const { | ||||
Q_UNUSED(parent); | Q_UNUSED(parent); | ||||
TransactionRecord *data = | TransactionRecord *data = | ||||
priv->index(walletModel->wallet(), walletModel->getNumBlocks(), row); | priv->index(walletModel->wallet(), | ||||
walletModel->clientModel().getBestBlockHash(), row); | |||||
if (data) { | if (data) { | ||||
return createIndex(row, column, data); | return createIndex(row, column, data); | ||||
} | } | ||||
return QModelIndex(); | return QModelIndex(); | ||||
} | } | ||||
void TransactionTableModel::updateDisplayUnit() { | void TransactionTableModel::updateDisplayUnit() { | ||||
// emit dataChanged to update Amount column with the current unit | // emit dataChanged to update Amount column with the current unit | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |