Skip to content

Commit

Permalink
fix: allow starting with no node synced
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo committed Jan 18, 2024
1 parent 1c6b221 commit b751163
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions pkg/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func logLevelFromString(level string) zerolog.Level {
func createNodePool(ctx context.Context, nodes []string) (*rpc.Pool, error) {
rpcNodes := make([]*rpc.Node, len(nodes))
for i, endpoint := range nodes {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()

client, err := http.New(endpoint, "/websocket")
Expand Down Expand Up @@ -234,20 +234,13 @@ func createNodePool(ctx context.Context, nodes []string) (*rpc.Pool, error) {
}
}

var rpcNode *rpc.Node
var chainID string
for _, node := range rpcNodes {
if chainID == "" {
chainID = node.ChainID()
} else if chainID != node.ChainID() && node.ChainID() != "" {
return nil, fmt.Errorf("nodes are on different chains: %s != %s", chainID, node.ChainID())
}
if node.IsSynced() {
rpcNode = node
}
}
if rpcNode == nil {
return nil, fmt.Errorf("no nodes synced")
}

return rpc.NewPool(chainID, rpcNodes), nil
Expand Down

0 comments on commit b751163

Please sign in to comment.