-
Notifications
You must be signed in to change notification settings - Fork 1
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
sync: Add rescan progress. #4
base: master
Are you sure you want to change the base?
Conversation
w.mainWallet = nil | ||
w.db = nil |
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.
Not related to the problem but I don't understand why this needs to be done and I'm concerned it could cause panics.
f8f2969
to
a28d2cf
Compare
if w.rescanning { | ||
w.syncStatusMtx.Unlock() | ||
return | ||
} |
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 looks like these are being called during the rescan, which is strange. This may be why the status doesnt say synced without the bandaid.
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.
We probably don't want to allow rescanning when sync is on. If we add that check in the rescan method, then we may not need to bother about this. w.Sync
should ideally stop calling these callbacks once the wallet is synced. But if it doesn't do so currently, then we'd need these if statements to play safe.
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.
We probably don't want to allow rescanning when sync is on.
Do you mean stop sync then restart it? Is that what other wallets do?
f8f2969
to
a28d2cf
Compare
if w.rescanning { | ||
w.syncStatusMtx.Unlock() | ||
return | ||
} |
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.
We probably don't want to allow rescanning when sync is on. If we add that check in the rescan method, then we may not need to bother about this. w.Sync
should ideally stop calling these callbacks once the wallet is synced. But if it doesn't do so currently, then we'd need these if statements to play safe.
return | ||
} | ||
w.syncStatusMtx.Lock() | ||
w.rescanHeight = int(p.ScannedThrough) |
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.
Do we want to set w.rescanHeight
at the beginning of the process?
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.
Yeah good idea, setting height at the beginning. Also moved the locks around.
cgo/walletloader.go
Outdated
if err := w.CloseWallet(); err != nil { | ||
return errCResponse("close wallet %q error: %v", name, err.Error()) | ||
} | ||
close(w.shutdown) | ||
w.Wait() |
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.
If rescan is in progress when w.CloseWallet()
is called, I'm not sure the rescan will be stopped before closing the wallet db? For sync for example, we call w.StopSync()
and w.WaitForSyncToStop()
in w.CloseWallet
before closing the wallet db.
Might be a good idea to do something similar for rescans. One approach would be to create a cancellable context in w.RescanProgressFromHeight
and cancel the context when w.CloseWallet()
is called. Would also need a way to ensure that the rescan has actually stopped before closing the wallet db.
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.
I thought closing the wallet db would just cause functions trying to use it to error?
so, close w.shutdown and wait before CloseWallet?
a28d2cf
to
7419307
Compare
I'm pretty sure decrediton and probably cryptopower allow rescanning while sync is active. But maybe not. Anyway I think this solves the other comments https://github.com/decred/libwallet/compare/a28d2cf76b1853ea81ca31b04847e786b512d1bf..7419307d7d5185ec785928157b296390dbde47d5 |
Ohh, are notifications only for initial sync? hmmm. I guess thats obvious but wasn't to me. So we don't need them at all after initial sync? |
We do want the peer notifications still. |
We can get the peers from the syncer. I can't think of a way to change this to actually lower allocations and what not at the moment. Maybe getting some of the notifications when we are not in initial sync is a wallet bug even. I think the rescanning checks in the notifications are enough for now. |
No description provided.