Skip to content

Commit

Permalink
fix: handle error on node start (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo authored Nov 20, 2023
1 parent 15d345d commit a89b3bc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/rpc/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ func NewPool(chainID string, nodes []*Node) *Pool {
}

func (p *Pool) Start(ctx context.Context) error {
errg, ctx := errgroup.WithContext(ctx)
for _, node := range p.Nodes {
node := node
// Start node
go node.Start(ctx)
errg.Go(func() error {
if err := node.Start(ctx); err != nil {
return fmt.Errorf("failed to start node %s: %w", node.Client.Remote(), err)
}
return nil
})

// Mark pool as started when the first node is started
go func() {
Expand All @@ -43,7 +49,7 @@ func (p *Pool) Start(ctx context.Context) error {
}
}()
}
return nil
return errg.Wait()
}

func (p *Pool) Stop(ctx context.Context) error {
Expand Down

0 comments on commit a89b3bc

Please sign in to comment.