-
Notifications
You must be signed in to change notification settings - Fork 123
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
Refactor and cleanup custodian events cache handling #756
Conversation
This commit refactors the method `Custodian.receiveProof` such that it's sync/goroutine agnostic (can be run with/without a goroutine). This change moves all goroutine wait group management code to the point where the goroutine is started. This commit modifies `receiveProof` such that it returns an error rather than writes an error directly to log. This means that we can pass the error to the custodian's error channel.
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 the refactor!
I think the first commit definitely makes sense. But the rest IMO make the already hard to follow flow even trickier...
What do you think of my suggestion to instead just feed the new proof into the main event loop to assert cleanup of the events?
7037869
to
f7e5951
Compare
Thanks for the review! I've gone with your idea. Reverted I'm still keen on the |
f7e5951
to
f2e8beb
Compare
This commit ensures that a proof received within a proof courier goroutine is fed into the proof subscription channel. This ensures that any event associated with the new proof will be cleaned up.
f2e8beb
to
58d4baa
Compare
I've taken a look at #726 and I've reduced the scope of this PR so that I don't get in its way: https://github.com/lightninglabs/taproot-assets/pull/726/files#diff-47500066f2e4b70c65d3c7777f4478203365bdfda9f82ae6602e9e853792efeb In other words, in this PR I've reverted my modifications to |
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.
Very nice, LGTM 🎉
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.
Nice clean-up, LGTM! 🥕
This PR makes the following changes:
Custodian.receiveProof
such that it can be executed without a new goroutine (I see this as a simplification: putting all goroutine/sync code in the same scope).mapProofToEvent
method. In this way,mapProofToEvent
only retrieves an event related to a given proof, and nothing more. Then, all event completion code is inCustodian.setReceiveCompleted
.