Skip to content

Question about duplicate Start() calls in LndChallenger initialization #169

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

Open
shaojunda opened this issue Apr 15, 2025 · 4 comments · May be fixed by #170
Open

Question about duplicate Start() calls in LndChallenger initialization #169

shaojunda opened this issue Apr 15, 2025 · 4 comments · May be fixed by #170

Comments

@shaojunda
Copy link

Description:

I noticed that the Start() method of LndChallenger is called twice during initialization:

  1. First call in NewLndChallenger (lnd.go#L68)
  2. The second call in NewLNCChallenger (lnc.go#L44)

While analyzing the Start() method implementation, I found that it:

  • Initializes invoice state tracking
  • Creates invoice subscriptions
  • Starts background goroutines

Questions:

  1. Is this double initialization intentional?
  2. If not, should we remove the Start() call from NewLndChallenger and let the caller handle initialization?

I'd appreciate any clarification on the design decision behind this pattern.

@guggero
Copy link
Member

guggero commented Apr 15, 2025

Those are two different kinds of challengers. One uses an lnd backend directly (over gRPC), the other uses an LNC connection.
So depending on which one the user configures, either one is created and therefore also needs to be started.

@guggero guggero closed this as completed Apr 15, 2025
@shaojunda
Copy link
Author

shaojunda commented Apr 15, 2025

I understand that these are two different challengers (direct LND and LNC), but in the case of LNCChallenger, it actually creates and starts the same LndChallenger instance twice:

  1. First Start() is called inside NewLndChallenger
  2. Then the same LndChallenger instance's Start() is called again in NewLNCChallenger

This means we're calling Start() on the same LndChallenger instance twice.

@shaojunda
Copy link
Author

To be more specific, in NewLNCChallenger, we first create a LndChallenger through NewLndChallenger, and then call Start() on that same instance again. This is why the same LndChallenger instance's Start() method gets called twice.

@guggero guggero reopened this Apr 15, 2025
@guggero
Copy link
Member

guggero commented Apr 15, 2025

Ah yeah, sorry. Looked at the code too superficially. I think it makes sense to remove the explicit call to lndChallenger.Start() within NewLNCChallenger.

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 a pull request may close this issue.

2 participants