-
Notifications
You must be signed in to change notification settings - Fork 267
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
Early subscribe core signals in transaction table model #121
Early subscribe core signals in transaction table model #121
Conversation
fc0803b
to
9267d2a
Compare
Please ignore whitespaces when reviewing. |
9267d2a
to
8b65985
Compare
Rebased due to conflict with updated #120. |
8b65985
to
0b0d91e
Compare
0b0d91e
to
5d7d363
Compare
Concept ACK. |
Yes, the current behavior is indeed buggy. It is easy to verify by patching |
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.
Approach ACK 5d7d363.
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.
Code review ACK 5d7d363. This looks good but is a pretty confusing change. I think it could be clearer split up into two commits: one pure refactoring commit replacing ShowProgress
with DispatchNotifications
, and another commit changing initialization order moving the subscribeToCoreSignals
call before the refreshWallet
call and adding the new DispatchNotifications
call at the end of the refreshWallet
implementation.
I will say I don't fully understand the motivation for the two refreshMethod
related changes. They seem safe but I don't know if they are actually changing behavior now or just setting something up for the future. If they were moved to standalone commit, purpose of the changes could be made more clear either in the commit description or code comments.
In case it helps other reviewers, I found the refactoring changes replacing ShowProgress
with DispatchNotifications
easier to understand after ignoring whitespace and rereading a previous explanation of the code #120 (comment).
Hebasto's suggestions also all seem reasonable and good. Basically a lot could be made clearer here, but this PR does seems fine to merge in its current form.
This PR might be interesting to people dealing with large wallets that have a lot of transactions, since it seems like it could help move to loading transactions asynchronously without locking up the GUI.
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.
Thanks for reviewing, I'll improve readability.
Concept ACK, thanks for working on that. |
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.
ACK 5d7d363, agree with #121 (review)
this PR does seems fine to merge in its current form.
5d7d363
to
8f16516
Compare
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.
Rebased and addressed @hebasto review.
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.
Approach ACK modulo that it's a fairly confusing change and separating into more commits may help here (as mentioned above).
8f16516
to
cafef08
Compare
Ok, I've tried to split in decent commits. |
{ | ||
for (const auto& wtx : wallet.getWalletTxs()) { | ||
if (TransactionRecord::showTransaction()) { | ||
cachedWallet.append(TransactionRecord::decomposeTransaction(wtx)); | ||
} | ||
} | ||
} | ||
m_loaded = true; |
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.
3bccd50 nit, can drop extra brackets
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 0175c88e7..8dc6d4c40 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -110,11 +110,9 @@ public:
void refreshWallet(interfaces::Wallet& wallet)
{
assert(!m_loaded);
- {
- for (const auto& wtx : wallet.getWalletTxs()) {
- if (TransactionRecord::showTransaction()) {
- cachedWallet.append(TransactionRecord::decomposeTransaction(wtx));
- }
+ for (const auto& wtx : wallet.getWalletTxs()) {
+ if (TransactionRecord::showTransaction()) {
+ cachedWallet.append(TransactionRecord::decomposeTransaction(wtx));
}
}
m_loaded = true;
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.
(similar to the change in the last commit, git show cafef080a2e --ignore-all-space
)
bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true)); | ||
assert(invoked); | ||
} | ||
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i) | ||
{ |
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.
cafef08 nit, while removing the brackets in this commit could also
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 0175c88e7..734605a47 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -739,8 +739,7 @@ void TransactionTablePriv::DispatchNotifications()
bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
assert(invoked);
}
- for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
- {
+ for (unsigned int i = 0; i < vQueueNotifications.size(); ++i) {
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.
tACK cafef08
happy to re-ACK for the above
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.
Thanks for splitting commits! Much easier to review.
bool fQueueNotifications = false; | ||
/** True when model finishes loading all wallet transactions on start */ | ||
bool m_loaded = false; | ||
/** True when transactions are being notified, for instance when scanning */ |
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.
It could be just my bad English, but it seems should be "... are not being notified", no?
If I'm correct, maybe re-word the comment in positive one?
Or maybe we think about different notifications: (a) from the node vs (b) to a user?
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.
Right, I'll rephrase.
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.
In commit "qt: Refactor ShowProgress to DispatchNotifications" (c6cbdf1)
re: #121 (comment)
Right, I'll rephrase.
If you're still planning to update this, my attempt at a comment would be: "This will be true when blocks in the chain are being scanned for new transactions, and transaction notification popups should be suppressed until the scan is done. It can be true even after m_loaded is true if a rescan has been triggered." I think I would also call this m_delay_notifications
instead of m_loading
because it can be true when m_loaded
is also true, but feel free to stick with whatever name you prefer.
std::vector< TransactionNotification > vQueueNotifications; | ||
|
||
void NotifyTransactionChanged(const uint256 &hash, ChangeType status); | ||
void ShowProgress(const std::string &title, int nProgress); | ||
void DispatchNotifications(); |
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.
A doxygen comment?
if (!m_loaded || m_loading) | ||
{ |
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.
style nit:
if (!m_loaded || m_loading) | |
{ | |
if (!m_loaded || m_loading) { |
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.
Code review ACK cafef08. Only change since last review is splitting commits and replacing m_progress with m_loading.
Thanks for the updates! I think this change is much easier to understand now.
It would be good to clarify in the PR description what exactly is meant by "This fixes the case where transaction notifications arrive between getWalletTxs
and subscribeToCoreSignals
." It's not clear from the description what the old behavior was and what the new behavior is.
IIUC, the problem was that notifications about new transactions discovered while the wallet was being loaded were dropped previously, and now they are shown?
bool fQueueNotifications = false; | ||
/** True when model finishes loading all wallet transactions on start */ | ||
bool m_loaded = false; | ||
/** True when transactions are being notified, for instance when scanning */ |
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.
In commit "qt: Refactor ShowProgress to DispatchNotifications" (c6cbdf1)
re: #121 (comment)
Right, I'll rephrase.
If you're still planning to update this, my attempt at a comment would be: "This will be true when blocks in the chain are being scanned for new transactions, and transaction notification popups should be suppressed until the scan is done. It can be true even after m_loaded is true if a rescan has been triggered." I think I would also call this m_delay_notifications
instead of m_loading
because it can be true when m_loaded
is also true, but feel free to stick with whatever name you prefer.
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.
Code review ACK cafef08
This fixes the case where transaction notifications arrive between
getWalletTxs
andsubscribeToCoreSignals
. Basically notifications are queued untilgetWalletTxs
and wallet rescan complete.This is also a requirement to call
getWalletTxs
in a background thread.Motivated by bitcoin/bitcoin#20241.