aperture
aperture copied to clipboard
Question about duplicate Start() calls in LndChallenger initialization
Description:
I noticed that the Start() method of LndChallenger is called twice during initialization:
- First call in
NewLndChallenger(lnd.go#L68) - 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:
- Is this double initialization intentional?
- If not, should we remove the
Start()call fromNewLndChallengerand let the caller handle initialization?
I'd appreciate any clarification on the design decision behind this pattern.
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.
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:
- First
Start()is called insideNewLndChallenger - Then the same
LndChallengerinstance'sStart()is called again inNewLNCChallenger
This means we're calling Start() on the same LndChallenger instance twice.
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.
Ah yeah, sorry. Looked at the code too superficially. I think it makes sense to remove the explicit call to lndChallenger.Start() within NewLNCChallenger.