-
Notifications
You must be signed in to change notification settings - Fork 47
RegisterSpendNtfn: support reorg channel #233
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
Conversation
Include lightninglabs/lndclient#233 RegisterSpendNtfn: support reorg channel TODO: remove replace in go.mod
Include lightninglabs/lndclient#233 RegisterSpendNtfn: support reorg channel TODO: remove replace in go.mod
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 feature!
chainnotifier_client.go
Outdated
return | ||
} | ||
|
||
opts.ReOrgChan <- struct{}{} |
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 think we should also listen on ctx.Done()
here, see RegisterConfirmationsNtfn
.
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.
On the same note, I think we should also do this before writing to the errChan
(and fix conf notifier too).
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 updated sending to ReOrgChan (listening for ctx.Done()
).
errChan
is used at most one time and it is buffered, has capacity 1.
But I think that we should listen for ctx.Done()
when sending to spendChan
and confChan
. These channels have capacity 1, but can be used multiple times.
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.
Fair point! Agree!
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.
Added this in another commit.
The corresponding API of LND already supports notifying the caller about a reorg. I reused NotifierOption's used for RegisterConfirmationsNtfn already to pass a channel notified upon a reorg affecting a reported confirmation.
Avoid a deadlock in case the caller doesn't consume notifications about spending or confirmations after cancelling a call.
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.
LGTM 🎉
Pushed a new tag: |
Include lightninglabs/lndclient#233 RegisterSpendNtfn: support reorg channel
Include lightninglabs/lndclient#233 RegisterSpendNtfn: support reorg channel
The corresponding API of LND already supports notifying the caller about a reorg. I reused NotifierOption's used for RegisterConfirmationsNtfn already to pass a channel notified upon a reorg affecting a reported confirmation.
Pull Request Checklist
in
lnd_services.go
are updated.macaroon_recipes.go
if your PR adds a new method that is calleddifferently than the RPC method it invokes.