-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(qt): refresh the whole wallet instead of processing individual updates for huge notification queues #5453
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ class TransactionTablePriv | |
void refreshWallet(interfaces::Wallet& wallet) | ||
{ | ||
qDebug() << "TransactionTablePriv::refreshWallet"; | ||
parent->beginResetModel(); | ||
cachedWallet.clear(); | ||
{ | ||
for (const auto& wtx : wallet.getWalletTxs()) { | ||
|
@@ -82,6 +83,7 @@ class TransactionTablePriv | |
} | ||
} | ||
} | ||
parent->endResetModel(); | ||
} | ||
|
||
/* Update our model of the wallet incrementally, to synchronize our model of the wallet | ||
|
@@ -244,6 +246,11 @@ TransactionTableModel::~TransactionTableModel() | |
delete priv; | ||
} | ||
|
||
void TransactionTableModel::refreshWallet() | ||
{ | ||
priv->refreshWallet(walletModel->wallet()); | ||
} | ||
|
||
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */ | ||
void TransactionTableModel::updateAmountColumnTitle() | ||
{ | ||
|
@@ -803,18 +810,24 @@ static void ShowProgress(TransactionTableModel *ttm, const std::string &title, i | |
if (nProgress == 100) | ||
{ | ||
fQueueNotifications = false; | ||
if (vQueueNotifications.size() > 10) { // prevent balloon spam, show maximum 10 balloons | ||
bool invoked = QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true)); | ||
assert(invoked); | ||
} | ||
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i) | ||
{ | ||
if (vQueueNotifications.size() - i <= 10) { | ||
bool invoked = QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false)); | ||
if (vQueueNotifications.size() < 10000) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you justify this magic number a bit more? why not 500 or 1k or 100k? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Processing 10K notifications worked ok-ish, with a slight delay for my 500k+ txes wallet. Processing 50-100k was already too slow comparing to refreshing the wallet instead. So I just kept 10k as a threshold. Could be higher or could be lower on different machines I guess, not sure how to pick the right number here. |
||
if (vQueueNotifications.size() > 10) { // prevent balloon spam, show maximum 10 balloons | ||
bool invoked = QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true)); | ||
assert(invoked); | ||
} | ||
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i) | ||
{ | ||
if (vQueueNotifications.size() - i <= 10) { | ||
bool invoked = QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false)); | ||
assert(invoked); | ||
} | ||
|
||
vQueueNotifications[i].invoke(ttm); | ||
vQueueNotifications[i].invoke(ttm); | ||
} | ||
} else { | ||
// it's much faster to just refresh the whole thing instead | ||
bool invoked = QMetaObject::invokeMethod(ttm, "refreshWallet", Qt::QueuedConnection); | ||
assert(invoked); | ||
} | ||
std::vector<TransactionNotification >().swap(vQueueNotifications); // clear | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be a valid state of parent if an exception would be thrown before
endResetModel()
is called?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. Not sure I get the question.. What kind of exception? And why you think it should affect
parent
(TransactionTableModel*
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://doc.qt.io/qt-6/qabstractitemmodel.html#endResetModel
I see that some methods doesn't have
noexcept
specifier, more over functions between beginResetModel() and endResetModel() such asgetWalletTxs
,showTransaction
have allocation inside: it means that any time an exception can be thrown.There're two possible solution for resolve "you must call" request:
lock_guard
that will call endResetModel() in a destructor.endResetModel