Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/horizon: Consolidate local captive core config steps #4940

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 == "" {
urvisavla marked this conversation as resolved.
Show resolved Hide resolved

// 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