File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 "context"
55 "crypto/ed25519"
66 "fmt"
7+ "slices"
78 "time"
89
910 "github.com/cenkalti/backoff"
@@ -245,6 +246,29 @@ func action(cli *cli.Context) error {
245246 }
246247 }()
247248
249+ // monitor node env updates in substrate url
250+ go func () {
251+ for {
252+ <- time .After (10 * time .Minute )
253+ newEnv , err := environment .Get ()
254+ if err != nil {
255+ log .Error ().Err (err ).Msg ("failed to get updated config" )
256+ continue
257+ }
258+ if ! slices .Equal (env .SubstrateURL , newEnv .SubstrateURL ) {
259+ sub , err = environment .GetSubstrate ()
260+ if err != nil {
261+ log .Error ().Err (err ).Msg ("failed to get updated substrate manager" )
262+ }
263+
264+ env = newEnv
265+ events .UpdateSubstrateManager (sub )
266+ log .Debug ().Strs ("substrate_urls" , newEnv .SubstrateURL ).Msg ("updated substrate events handler to use new substrate urls" )
267+
268+ }
269+ }
270+ }()
271+
248272 log .Info ().Uint32 ("twin" , twin ).Msg ("node has been registered" )
249273 idStub := stubs .NewIdentityManagerStub (redis )
250274 fetchCtx , cancel := context .WithTimeout (ctx , 30 * time .Second )
You can’t perform that action at this time.
0 commit comments