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

Pass context.Context to GetUtxo #2770

Closed
wants to merge 5 commits into from

Conversation

halseth
Copy link
Contributor

@halseth halseth commented Mar 13, 2019

Alternative to #2716

This will make sure a long-running rescan can be canceled in case
Neutrino is the backend.
This will make sure a long-running rescan can be canceled in the case
the notifier is shutting down.
@@ -972,10 +973,26 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
)
if err != nil {
}

ctx, cancel := context.WithCancel(context.Background())
Copy link
Contributor

Choose a reason for hiding this comment

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

since our goal is simply to break on shutdown, we should only need to make one context.Context for the whole LightningWallet. the ctx and cancel can be tracked as member variables, and cancel only needs to invoked when Stopis called. similar comment applies for router

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but that seems like a big deviation from our normal pattern? I like sticking with the simple cancel chan tbh.

Copy link
Contributor

Choose a reason for hiding this comment

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

what's the normal pattern? having one context for all concurrent wallet/router GetUtxo requests seems more in line with how we would otherwise pass the object's quit channel, like in #2716?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think having a context.Background makes sense for the struct itself. We can then use specific deadlines/cancels by creating a context specific for that call, like we do with the integration tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like sticking with the simple cancel chan tbh.

Do you mean quit chans or cancel() funcs?

I think having a context.Background makes sense for the struct itself. We can then use specific deadlines/cancels by creating a context specific for that call, like we do with the integration tests.

Agreed, though it's not necessary to create a cancellable context for each call when our only need is to cancel them all simultaneously. If in the future we want to be able to cancel/timeout individual calls, then creating a subcontext would be appropriate. In the meantime it is extra goroutine overhead

atm i'm kind of in favor of #2716 for simplicity, it matches the existing patterns w/in the codebase, and accomplishes the same task w/ less overhead

Copy link
Contributor Author

@halseth halseth Mar 22, 2019

Choose a reason for hiding this comment

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

Do you mean quit chans or cancel() funcs?

I meant as in #2716

what's the normal pattern?

That is " it matches the existing patterns w/in the codebase", and I'm also in favor of #2716 for now.

@cfromknecht
Copy link
Contributor

Closing since #2716 was merged

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

3 participants