Skip to content

Commit

Permalink
services/horizon: Consolidate local captive core config steps in sing…
Browse files Browse the repository at this point in the history
…le 'if'
  • Loading branch information
urvisavla committed Jun 30, 2023
1 parent 2ec1834 commit c4f0bae
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,18 +650,23 @@ func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOption
viper.Set(StellarCoreBinaryPathName, binaryPath)
config.CaptiveCoreBinaryPath = binaryPath
}
} else {
config.CaptiveCoreBinaryPath = binaryPath
}
}

// Create config for local captive core
if config.EnableCaptiveCoreIngestion && config.RemoteCaptiveCoreURL == "" {

// NOTE: If both of these are set (regardless of user- or PATH-supplied
// defaults for the binary path), the Remote Captive Core URL
// takes precedence.
if binaryPath == "" && config.RemoteCaptiveCoreURL == "" {
if config.CaptiveCoreBinaryPath == "" {
return fmt.Errorf("Invalid config: captive core requires that either --%s or --remote-captive-core-url is set. %s",
StellarCoreBinaryPathName, captiveCoreMigrationHint)
}

config.CaptiveCoreTomlParams.CoreBinaryPath = binaryPath
if config.RemoteCaptiveCoreURL == "" && (binaryPath == "" || config.CaptiveCoreConfigPath == "") {
config.CaptiveCoreTomlParams.CoreBinaryPath = config.CaptiveCoreBinaryPath
if config.CaptiveCoreConfigPath == "" {
if options.RequireCaptiveCoreConfig {
var err error
errorMessage := fmt.Errorf(
Expand Down Expand Up @@ -707,7 +712,7 @@ func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOption
return fmt.Errorf("Invalid captive core toml file %v", err)
}
}
} else if config.RemoteCaptiveCoreURL == "" {
} else {
var err error
config.CaptiveCoreTomlParams.HistoryArchiveURLs = config.HistoryArchiveURLs
config.CaptiveCoreTomlParams.NetworkPassphrase = config.NetworkPassphrase
Expand All @@ -719,7 +724,7 @@ func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOption

// If we don't supply an explicit core URL and we are running a local
// captive core process with the http port enabled, point to it.
if config.StellarCoreURL == "" && config.RemoteCaptiveCoreURL == "" && config.CaptiveCoreToml.HTTPPort != 0 {
if config.StellarCoreURL == "" && config.CaptiveCoreToml.HTTPPort != 0 {
config.StellarCoreURL = fmt.Sprintf("http://localhost:%d", config.CaptiveCoreToml.HTTPPort)
viper.Set(StellarCoreURLFlagName, config.StellarCoreURL)
}
Expand Down

0 comments on commit c4f0bae

Please sign in to comment.