Skip to content
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

fix: Client::has_pending_recoveries #4462

Merged
merged 1 commit into from
Mar 5, 2024
Merged

Conversation

maan2003
Copy link
Member

@maan2003 maan2003 commented Mar 5, 2024

earlier it returned true if client_recovery_progress_receiver returned empty btreemap

earlier it returned true if client_recovery_progress_receiver returned empty btreemap
@maan2003 maan2003 requested a review from a team as a code owner March 5, 2024 12:40
Copy link
Member

@bradleystachurski bradleystachurski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Out of curiosity, how'd you find this? I don't see any usages of has_pending_recoveries in this repo.

@maan2003
Copy link
Member Author

maan2003 commented Mar 5, 2024

Nice catch! Out of curiosity, how'd you find this? I don't see any usages of has_pending_recoveries in this repo.

we are using it in fedi

@dpc dpc enabled auto-merge March 5, 2024 20:21
@dpc dpc added this pull request to the merge queue Mar 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 5, 2024
@dpc dpc added this pull request to the merge queue Mar 5, 2024
Merged via the queue into fedimint:master with commit 91a80b3 Mar 5, 2024
19 of 20 checks passed
@@ -1470,7 +1470,7 @@ impl Client {
.client_recovery_progress_receiver
.borrow()
.iter()
.any(|(_id, progress)| !progress.is_done())
.all(|(_id, progress)| progress.is_done())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this fn was that it returned the opposite of what its name suggests, you could have just flipped the negation on line 1469 😅

!any(!done) == all(done) // What we had
any(!done) == !all(done) // What we want

Someone likely just confused themselves with all these negations when writing this initially.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The any vs all behavior on empty is tricky. Maybe this whole methods should have been are_all_recoveries_done indeed. I kind of wrote it just to show it's now possible to have APIs like that (including subscribing to updates), and the code is not used anywhere which means that 99% it doesn't work. :D

@maan2003 As you are working on integrating this in Fedi app, don't be afraid to completely change anything there. IMO, the most useful part of TDD is that only when you actually write the user code, you have a good feel for what good API should look like. And when you don't, you get buggy code and bad APIs. (like I did here) :D

@maan2003 maan2003 deleted the push-nvtxtxqqmvpr branch March 21, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants