@@ -71,7 +71,7 @@ type Registrar struct {
71
71
mutex sync.RWMutex
72
72
}
73
73
74
- func NewRegistrar (ctx context.Context , cl zbus.Client , env environment. Environment , info RegistrationInfo ) * Registrar {
74
+ func NewRegistrar (ctx context.Context , cl zbus.Client , info RegistrationInfo ) * Registrar {
75
75
r := Registrar {
76
76
State {
77
77
0 ,
@@ -82,7 +82,7 @@ func NewRegistrar(ctx context.Context, cl zbus.Client, env environment.Environme
82
82
sync.RWMutex {},
83
83
}
84
84
85
- go r .register (ctx , cl , env , info )
85
+ go r .register (ctx , cl , info )
86
86
return & r
87
87
}
88
88
@@ -100,7 +100,7 @@ func (r *Registrar) getState() State {
100
100
101
101
// register a node and then blocks forever watching the node account. It tries to re-activate the
102
102
// account if needed
103
- func (r * Registrar ) register (ctx context.Context , cl zbus.Client , env environment. Environment , info RegistrationInfo ) {
103
+ func (r * Registrar ) register (ctx context.Context , cl zbus.Client , info RegistrationInfo ) {
104
104
if app .CheckFlag (app .LimitedCache ) {
105
105
r .setState (FailedState (errors .New ("no disks" )))
106
106
return
@@ -116,6 +116,7 @@ func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environmen
116
116
bo := backoff .WithContext (exp , ctx )
117
117
register := func () {
118
118
err := backoff .RetryNotify (func () error {
119
+ env := environment .MustGet ()
119
120
nodeID , twinID , err := r .registration (ctx , cl , env , info )
120
121
if err != nil {
121
122
r .setState (FailedState (err ))
@@ -145,6 +146,7 @@ func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environmen
145
146
select {
146
147
case <- ctx .Done ():
147
148
case <- time .After (monitorAccountEvery ):
149
+ env := environment .MustGet ()
148
150
if err := r .reActivate (ctx , cl , env ); err != nil {
149
151
log .Error ().Err (err ).Msg ("failed to reactivate account" )
150
152
}
0 commit comments