Skip to content

Commit

Permalink
assume blockchain endpoint only for cli managed node sync
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Oct 12, 2024
1 parent b2d4e4d commit 340d2cf
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pkg/contract/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,7 @@ func GetBlockchainEndpoints(
rpcEndpoint string
wsEndpoint string
)
switch {
case chainSpec.CChain:
rpcEndpoint = network.CChainEndpoint()
wsEndpoint = network.CChainWSEndpoint()
case network.Kind == models.Local || network.Kind == models.Devnet:
blockchainID, err := GetBlockchainID(app, network, chainSpec)
if err != nil {
return "", "", err
}
rpcEndpoint = network.BlockchainEndpoint(blockchainID.String())
wsEndpoint = network.BlockchainWSEndpoint(blockchainID.String())
case chainSpec.BlockchainName != "":
if chainSpec.BlockchainName != "" {
sc, err := app.LoadSidecar(chainSpec.BlockchainName)
if err != nil {
return "", "", fmt.Errorf("failed to load sidecar: %w", err)
Expand All @@ -125,6 +114,20 @@ func GetBlockchainEndpoints(
wsEndpoint = sc.Networks[network.Name()].WSEndpoints[0]
}
}
if rpcEndpoint == "" {
switch {
case chainSpec.CChain:
rpcEndpoint = network.CChainEndpoint()
wsEndpoint = network.CChainWSEndpoint()
case network.Kind == models.Local:
blockchainID, err := GetBlockchainID(app, network, chainSpec)
if err != nil {
return "", "", err
}
rpcEndpoint = network.BlockchainEndpoint(blockchainID.String())
wsEndpoint = network.BlockchainWSEndpoint(blockchainID.String())
}
}
blockchainDesc, err := GetBlockchainDesc(chainSpec)
if err != nil {
return "", "", err
Expand Down

0 comments on commit 340d2cf

Please sign in to comment.