diff --git a/services/horizon/internal/flags.go b/services/horizon/internal/flags.go index 1588361c2b..f876f54137 100644 --- a/services/horizon/internal/flags.go +++ b/services/horizon/internal/flags.go @@ -121,6 +121,7 @@ func Flags() (*Config, support.ConfigOptions) { EnvVar: "STELLAR_CORE_DATABASE_URL", ConfigKey: &config.StellarCoreDatabaseURL, OptType: types.String, + Required: false, Usage: "stellar-core postgres database to connect with", }, &support.ConfigOption{ @@ -359,10 +360,8 @@ func NewAppFromFlags(config *Config, flags support.ConfigOptions) *App { if config.StellarCoreURL == "" { log.Fatalf("flag --%s cannot be empty", StellarCoreURLFlagName) } - if config.Ingest { - if config.StellarCoreDatabaseURL == "" { - log.Fatalf("flag --%s cannot be empty", StellarCoreDBURLFlagName) - } + if config.Ingest && !config.EnableCaptiveCoreIngestion && config.StellarCoreDatabaseURL == "" { + log.Fatalf("flag --%s cannot be empty", StellarCoreDBURLFlagName) } app, err := NewApp(*config) if err != nil { diff --git a/services/horizon/internal/init.go b/services/horizon/internal/init.go index 4445ec7605..fa76eb1763 100644 --- a/services/horizon/internal/init.go +++ b/services/horizon/internal/init.go @@ -52,10 +52,12 @@ func mustInitHorizonDB(app *App) { func initExpIngester(app *App) { var err error + var coreSession *db.Session + if !app.config.EnableCaptiveCoreIngestion { + coreSession = mustNewDBSession(app.config.StellarCoreDatabaseURL, ingest.MaxDBConnections, ingest.MaxDBConnections) + } app.ingester, err = ingest.NewSystem(ingest.Config{ - CoreSession: mustNewDBSession( - app.config.StellarCoreDatabaseURL, ingest.MaxDBConnections, ingest.MaxDBConnections, - ), + CoreSession: coreSession, HistorySession: mustNewDBSession( app.config.DatabaseURL, ingest.MaxDBConnections, ingest.MaxDBConnections, ),