multi: initialize block height in New, not in Run

If Run sets the current height field, it is technically a race between Run and
other methods reading the field. Setting in New is a safer option.

Removed a check that height is not 0 from static address manager.
This commit is contained in:
Boris Nagaev 2025-03-14 14:16:07 -03:00 committed by Slyghtning
parent 3cbfadd27a
commit dc4a5641ac
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
6 changed files with 46 additions and 69 deletions

View file

@ -41,18 +41,17 @@ type Manager struct {
}
// NewInstantOutManager creates a new instantout manager.
func NewInstantOutManager(cfg *Config) *Manager {
func NewInstantOutManager(cfg *Config, height int32) *Manager {
return &Manager{
cfg: cfg,
activeInstantOuts: make(map[lntypes.Hash]*FSM),
blockEpochChan: make(chan int32),
currentHeight: height,
}
}
// Run runs the instantout manager.
func (m *Manager) Run(ctx context.Context, initChan chan struct{},
height int32) error {
func (m *Manager) Run(ctx context.Context, initChan chan struct{}) error {
log.Debugf("Starting instantout manager")
defer func() {
log.Debugf("Stopping instantout manager")
@ -62,7 +61,6 @@ func (m *Manager) Run(ctx context.Context, initChan chan struct{},
defer cancel()
m.runCtx = runCtx
m.currentHeight = height
err := m.recoverInstantOuts(runCtx)
if err != nil {