From d7fcef9c147fb37228e05ee0f3e6e971523d2816 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Tue, 10 Dec 2024 11:29:06 +1100 Subject: [PATCH] refactor: Add NotOptimisticEL method to Nodes type --- pkg/beacon/nodes.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pkg/beacon/nodes.go b/pkg/beacon/nodes.go index a98e0a1..15dfd4b 100644 --- a/pkg/beacon/nodes.go +++ b/pkg/beacon/nodes.go @@ -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) } @@ -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) {