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
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions services/horizon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

- The command line flag --remote-captive-core-url has been removed as remote captive core functionality is now deprecated ([4940](https://github.com/stellar/go/pull/4940)).

## 2.26.0
### Changes
Expand Down
35 changes: 12 additions & 23 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,9 @@ func Flags() (*Config, support.ConfigOptions) {
OptType: types.String,
FlagDefault: "",
Required: false,
Usage: "path to stellar core binary (--remote-captive-core-url has higher precedence). If captive core is enabled, look for the stellar-core binary in $PATH by default.",
Usage: "path to stellar core binary, look for the stellar-core binary in $PATH by default.",
ConfigKey: &config.CaptiveCoreBinaryPath,
},
&support.ConfigOption{
Name: "remote-captive-core-url",
OptType: types.String,
FlagDefault: "",
Required: false,
Usage: "url to access the remote captive core server",
ConfigKey: &config.RemoteCaptiveCoreURL,
},
&support.ConfigOption{
Name: captiveCoreConfigAppendPathName,
OptType: types.String,
Expand Down Expand Up @@ -649,24 +641,21 @@ func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOption
binaryPath = result
viper.Set(StellarCoreBinaryPathName, binaryPath)
config.CaptiveCoreBinaryPath = binaryPath
} else {
return fmt.Errorf("invalid config: captive core requires --%s. %s",
StellarCoreBinaryPathName, captiveCoreMigrationHint)
}
} else {
config.CaptiveCoreBinaryPath = binaryPath
}

// 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 == "" {
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(
"Invalid config: captive core requires that both --%s and --%s are set. %s",
StellarCoreBinaryPathName, CaptiveCoreConfigPathName, captiveCoreMigrationHint,
"invalid config: captive core requires that --%s is set. %s",
CaptiveCoreConfigPathName, captiveCoreMigrationHint,
)

var configFileName string
Expand Down Expand Up @@ -707,7 +696,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 +708,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