Skip to content

Commit

Permalink
feat: finished autoselect version feature
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler committed Nov 20, 2024
1 parent e296125 commit 1b010d3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions cmd/ksync/commands/blocksync.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ var blockSyncCmd = &cobra.Command{
logger.Info().Msgf("loaded source \"%s\" from genesis file", source)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("loaded engine \"%s\" from binary path", engine)
}

bId, _, err := sources.GetPoolIds(chainId, source, blockPoolId, "", registryUrl, true, false)
if err != nil {
return fmt.Errorf("failed to load pool-ids: %w", err)
Expand Down Expand Up @@ -131,6 +126,11 @@ var blockSyncCmd = &cobra.Command{
return fmt.Errorf("failed to check if binary has the recommended version: %w", err)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("loaded engine \"%s\" from binary path", engine)
}

consensusEngine, err := engines.EngineSourceFactory(engine, homePath, registryUrl, source, rpcServerPort, continuationHeight)
if err != nil {
return fmt.Errorf("failed to create consensus engine for source: %w", err)
Expand Down
10 changes: 5 additions & 5 deletions cmd/ksync/commands/heightsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ var heightSyncCmd = &cobra.Command{
homePath = utils.GetHomePathFromBinary(binaryPath)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("Loaded engine \"%s\" from binary path", engine)
}

defaultEngine := engines.EngineFactory(engine, homePath, rpcServerPort)

if source == "" && blockPoolId == "" && snapshotPoolId == "" {
Expand Down Expand Up @@ -140,6 +135,11 @@ var heightSyncCmd = &cobra.Command{
return fmt.Errorf("failed to check if binary has the recommended version: %w", err)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("Loaded engine \"%s\" from binary path", engine)
}

consensusEngine, err := engines.EngineSourceFactory(engine, homePath, registryUrl, source, rpcServerPort, continuationHeight)
if err != nil {
return fmt.Errorf("failed to create consensus engine for source: %w", err)
Expand Down
10 changes: 5 additions & 5 deletions cmd/ksync/commands/serveblocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ var serveBlocksCmd = &cobra.Command{
homePath = utils.GetHomePathFromBinary(binaryPath)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("Loaded engine \"%s\" from binary path", engine)
}

defaultEngine := engines.EngineFactory(engine, homePath, rpcServerPort)

if source == "" && blockPoolId == "" {
Expand Down Expand Up @@ -120,6 +115,11 @@ var serveBlocksCmd = &cobra.Command{
return fmt.Errorf("failed to check if binary has the recommended version: %w", err)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("Loaded engine \"%s\" from binary path", engine)
}

consensusEngine, err := engines.EngineSourceFactory(engine, homePath, registryUrl, source, rpcServerPort, continuationHeight)
if err != nil {
return fmt.Errorf("failed to create consensus engine for source: %w", err)
Expand Down
10 changes: 5 additions & 5 deletions cmd/ksync/commands/servesnapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ var servesnapshotsCmd = &cobra.Command{
homePath = utils.GetHomePathFromBinary(binaryPath)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("Loaded engine \"%s\" from binary path", engine)
}

defaultEngine := engines.EngineFactory(engine, homePath, rpcServerPort)

if source == "" && blockPoolId == "" && snapshotPoolId == "" {
Expand Down Expand Up @@ -133,6 +128,11 @@ var servesnapshotsCmd = &cobra.Command{
return fmt.Errorf("failed to check if binary has the recommended version: %w", err)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("Loaded engine \"%s\" from binary path", engine)
}

consensusEngine, err := engines.EngineSourceFactory(engine, homePath, registryUrl, source, rpcServerPort, continuationHeight)
if err != nil {
return fmt.Errorf("failed to create consensus engine for source: %w", err)
Expand Down
10 changes: 5 additions & 5 deletions cmd/ksync/commands/statesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ var stateSyncCmd = &cobra.Command{
homePath = utils.GetHomePathFromBinary(binaryPath)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("Loaded engine \"%s\" from binary path", engine)
}

defaultEngine := engines.EngineFactory(engine, homePath, rpcServerPort)

if source == "" && snapshotPoolId == "" {
Expand Down Expand Up @@ -105,6 +100,11 @@ var stateSyncCmd = &cobra.Command{
return fmt.Errorf("failed to check if binary has the recommended version: %w", err)
}

if engine == "" && binaryPath != "" {
engine = utils.GetEnginePathFromBinary(binaryPath)
logger.Info().Msgf("Loaded engine \"%s\" from binary path", engine)
}

consensusEngine, err := engines.EngineSourceFactory(engine, homePath, registryUrl, source, rpcServerPort, snapshotHeight)
if err != nil {
return fmt.Errorf("failed to create consensus engine for source: %w", err)
Expand Down

0 comments on commit 1b010d3

Please sign in to comment.