mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
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:
parent
3cbfadd27a
commit
dc4a5641ac
6 changed files with 46 additions and 69 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue