-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Synchronized Spend and Epoch Notification Cancellation #239
Synchronized Spend and Epoch Notification Cancellation #239
Conversation
@cfromknecht, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Roasbeef, @AndrewSamokhvalov and @bryanvu to be potential reviewers. |
ffb9d3b
to
c886b2d
Compare
2a096da
to
c4cf854
Compare
c4cf854
to
e1fc54e
Compare
e1fc54e
to
fcf1969
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.
Nice approach in ensuring that the clients will never read from a closed channel! The new cancellation scheme results in very tight synchronization between the caller and the ChainNotifier
instance. I've verified locally that this addresses the flakes referenced in the PR's body.
LGTM 👾
Makes cancellation of neutrino and btcd notifications block until notification dispatcher has processed the cancellation request. This commit also unifies the logic across all cancellation handling in regards to formatting and documentation.
The issue is primarily created because of a quirk in go, allowing buffered channels to be read after they have been closed. The solution is to ensure the notification channels are properly drained and closed before yielding to the caller of Cancel. By doing so, we can ensure that the channel is both empty and closed before allowing the caller to attempt a read on the buffered channel. Under this proposal, we can safely remove the use of done channels used to synchronize epoch cancellation since draining the channel is sufficient to ensure that the cancellation has been processed by the notification dispatcher and that the client is guaranteed to see a closed channel, as intended.
Example Errors
Blocking Drain of Epoch Event Channel