Skip to content

Commit b5cf638

Browse files
committed
pkg/loop: wait from chain family
1 parent 8fd3a49 commit b5cf638

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

pkg/loop/internal/goplugin/plugin_service.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,16 @@ func (s *PluginService[P, S]) WaitCtx(ctx context.Context) error {
261261
}
262262
}
263263

264+
// Wait waits for the service to start up until it receives the stop signal.
265+
func (s *PluginService[P, S]) Wait() error {
266+
select {
267+
case <-s.serviceCh:
268+
return nil
269+
case <-s.stopCh:
270+
return fmt.Errorf("service was stoped while waiting: %w", context.Canceled)
271+
}
272+
}
273+
264274
// XXXTestHook returns a TestPluginService.
265275
// It must only be called once, and before Start.
266276
func (s *PluginService[P, S]) XXXTestHook() TestPluginService[P, S] {

pkg/loop/relayer_service.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ func NewRelayerService(lggr logger.Logger, grpcOpts GRPCOpts, cmd func() *exec.C
4343
}
4444

4545
func (r *RelayerService) EVM() (types.EVMService, error) {
46+
if err := r.Wait(); err != nil {
47+
return nil, err
48+
}
4649
return r.Service.EVM()
4750
}
4851

4952
func (r *RelayerService) TON() (types.TONService, error) {
53+
if err := r.Wait(); err != nil {
54+
return nil, err
55+
}
5056
return r.Service.TON()
5157
}
5258

0 commit comments

Comments
 (0)