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: Refactor handling of stellar-core-binary-path #3101

Merged
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
8 changes: 4 additions & 4 deletions services/horizon/cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ var dbReingestRangeCmd = &cobra.Command{
HistoryArchiveURL: config.HistoryArchiveURLs[0],
MaxReingestRetries: int(retries),
ReingestRetryBackoffSeconds: int(retryBackoffSeconds),
EnableCaptiveCore: config.EnableCaptiveCoreIngestion,
StellarCoreBinaryPath: config.StellarCoreBinaryPath,
RemoteCaptiveCoreURL: config.RemoteCaptiveCoreURL,
}

if config.EnableCaptiveCoreIngestion {
ingestConfig.StellarCoreBinaryPath = config.StellarCoreBinaryPath
ingestConfig.RemoteCaptiveCoreURL = config.RemoteCaptiveCoreURL
} else {
if !ingestConfig.EnableCaptiveCore {
if config.StellarCoreDatabaseURL == "" {
log.Fatalf("flag --%s cannot be empty", stellarCoreDBURLFlagName)
}
Expand Down
15 changes: 8 additions & 7 deletions services/horizon/cmd/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ var ingestVerifyRangeCmd = &cobra.Command{
}

ingestConfig := expingest.Config{
NetworkPassphrase: config.NetworkPassphrase,
HistorySession: horizonSession,
HistoryArchiveURL: config.HistoryArchiveURLs[0],
NetworkPassphrase: config.NetworkPassphrase,
HistorySession: horizonSession,
HistoryArchiveURL: config.HistoryArchiveURLs[0],
EnableCaptiveCore: config.EnableCaptiveCoreIngestion,
StellarCoreBinaryPath: config.StellarCoreBinaryPath,
RemoteCaptiveCoreURL: config.RemoteCaptiveCoreURL,
}
if config.EnableCaptiveCoreIngestion {
ingestConfig.StellarCoreBinaryPath = config.StellarCoreBinaryPath
ingestConfig.RemoteCaptiveCoreURL = config.RemoteCaptiveCoreURL
} else {

if !ingestConfig.EnableCaptiveCore {
if config.StellarCoreDatabaseURL == "" {
log.Fatalf("flag --%s cannot be empty", stellarCoreDBURLFlagName)
}
Expand Down
5 changes: 1 addition & 4 deletions services/horizon/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ var configOpts = support.ConfigOptions{
OptType: types.String,
FlagDefault: "",
Required: false,
Usage: "path to stellar core binary",
Usage: "path to stellar core binary (--remote-captive-core-url has higher precedence)",
ConfigKey: &config.StellarCoreBinaryPath,
},
&support.ConfigOption{
Expand Down Expand Up @@ -429,9 +429,6 @@ func initRootConfig() {
if binaryPath == "" && remoteURL == "" {
stdLog.Fatalf("Invalid config: captive core requires that either --stellar-core-binary-path or --remote-captive-core-url is set")
}
if binaryPath != "" && remoteURL != "" {
stdLog.Fatalf("Invalid config: --stellar-core-binary-path and --remote-captive-core-url cannot both be set.")
}
}
if config.Ingest {
// When running live ingestion a config file is required too
Expand Down
37 changes: 20 additions & 17 deletions services/horizon/internal/expingest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Config struct {
CoreSession *db.Session
StellarCoreURL string
StellarCoreCursor string
EnableCaptiveCore bool
StellarCoreBinaryPath string
StellarCoreConfigPath string
RemoteCaptiveCoreURL string
Expand Down Expand Up @@ -157,23 +158,25 @@ func NewSystem(config Config) (System, error) {
}

var ledgerBackend ledgerbackend.LedgerBackend
if len(config.RemoteCaptiveCoreURL) > 0 {
ledgerBackend, err = ledgerbackend.NewRemoteCaptive(config.RemoteCaptiveCoreURL)
if err != nil {
cancel()
return nil, errors.Wrap(err, "error creating captive core backend")
}
}
if len(config.StellarCoreBinaryPath) > 0 {
ledgerBackend, err = ledgerbackend.NewCaptive(
config.StellarCoreBinaryPath,
config.StellarCoreConfigPath,
config.NetworkPassphrase,
[]string{config.HistoryArchiveURL},
)
if err != nil {
cancel()
return nil, errors.Wrap(err, "error creating captive core backend")
if config.EnableCaptiveCore {
if len(config.RemoteCaptiveCoreURL) > 0 {
ledgerBackend, err = ledgerbackend.NewRemoteCaptive(config.RemoteCaptiveCoreURL)
if err != nil {
cancel()
return nil, errors.Wrap(err, "error creating captive core backend")
}
} else {
//
ledgerBackend, err = ledgerbackend.NewCaptive(
config.StellarCoreBinaryPath,
config.StellarCoreConfigPath,
config.NetworkPassphrase,
[]string{config.HistoryArchiveURL},
)
if err != nil {
cancel()
return nil, errors.Wrap(err, "error creating captive core backend")
}
}
} else {
coreSession := config.CoreSession.Clone()
Expand Down