File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -694,6 +694,8 @@ func (b *Bootstrap) Run(
694694 // mark ready
695695 ready ()
696696
697+ go b .trackOperatorBalance (ctx )
698+
697699 return nil
698700}
699701
@@ -707,6 +709,26 @@ func (b *Bootstrap) Stop() {
707709 b .StopDB ()
708710}
709711
712+ func (b * Bootstrap ) trackOperatorBalance (ctx context.Context ) {
713+ ticker := time .NewTicker (1 * time .Minute )
714+ defer ticker .Stop ()
715+
716+ for {
717+ select {
718+ case <- ctx .Done ():
719+ return
720+ case <- ticker .C :
721+ accBalance , err := b .client .GetAccountBalanceAtLatestBlock (ctx , b .config .COAAddress )
722+ if err != nil {
723+ b .logger .Warn ().Err (err ).Msg (
724+ "failed to collect operator's balance metric" ,
725+ )
726+ }
727+ b .collector .OperatorBalance (accBalance )
728+ }
729+ }
730+ }
731+
710732// Run will run complete bootstrap of the EVM gateway with all the engines.
711733// Run is a blocking call, but it does signal readiness of the service
712734// through a channel provided as an argument.
You can’t perform that action at this time.
0 commit comments