accounts/usbwallet: fix De Morgan error dropping stale wallets on refresh#35150
Open
cuiweixie wants to merge 1 commit into
Open
accounts/usbwallet: fix De Morgan error dropping stale wallets on refresh#35150cuiweixie wants to merge 1 commit into
cuiweixie wants to merge 1 commit into
Conversation
…resh
The inner loop in refreshWallets drops cached wallets that sort before
the next enumerated device or that have failed. When this drop-while
logic was refactored into an early break, the condition was negated but
the boolean operator was left as ||, so the negation is incomplete.
The drop condition is:
(URL.Cmp(url) < 0) || (failure != nil)
so the break (abort dropping) condition must be its De Morgan negation:
(URL.Cmp(url) >= 0) && (failure == nil)
With ||, the loop breaks as soon as the front wallet is operational,
even when it sorts before the current device. The stale wallet is not
dropped in place, and neither the "wrap new wallet" nor the "keep
matching wallet" branch matches, so the still-present device is silently
skipped for that refresh cycle (no WalletArrived) and is only re-added
on a later refresh.
Switch the operator to && so the break condition correctly mirrors the
intended drop semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The inner loop in refreshWallets drops cached wallets that sort before the next enumerated device or that have failed. When this drop-while logic was refactored into an early break, the condition was negated but the boolean operator was left as ||, so the negation is incomplete.
The drop condition is:
so the break (abort dropping) condition must be its De Morgan negation:
With ||, the loop breaks as soon as the front wallet is operational, even when it sorts before the current device. The stale wallet is not dropped in place, and neither the "wrap new wallet" nor the "keep matching wallet" branch matches, so the still-present device is silently skipped for that refresh cycle (no WalletArrived) and is only re-added on a later refresh.
Switch the operator to && so the break condition correctly mirrors the intended drop semantics.