Skip to content

Commit

Permalink
refactor: Add NotOptimisticEL method to Nodes type
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Dec 10, 2024
1 parent e762af3 commit d7fcef9
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/beacon/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func (n Nodes) Healthy(ctx context.Context) Nodes {
continue
}

_, err := node.Beacon.Genesis()
if err != nil {
continue
}

nodes = append(nodes, node)
}

Expand Down Expand Up @@ -116,10 +121,25 @@ func (n Nodes) Syncing(ctx context.Context) Nodes {
return nodes
}

func (n Nodes) NotOptimisticEL(ctx context.Context) Nodes {
nodes := []*Node{}

for _, node := range n {
if node.Beacon.Status().SyncState().IsOptimistic {
continue
}

nodes = append(nodes, node)
}

return nodes
}

func (n Nodes) Ready(ctx context.Context) Nodes {
return n.
Healthy(ctx).
NotSyncing(ctx)
NotSyncing(ctx).
NotOptimisticEL(ctx)
}

func (n Nodes) RandomNode(ctx context.Context) (*Node, error) {
Expand Down

0 comments on commit d7fcef9

Please sign in to comment.