Skip to content

Commit

Permalink
Add timeout for initializing captive core
Browse files Browse the repository at this point in the history
  • Loading branch information
stellarsaur committed Nov 30, 2023
1 parent d5acaf4 commit 0068aca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/soroban-rpc/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
FriendbotURL string
HistoryArchiveURLs []string
IngestionTimeout time.Duration
CaptiveCoreTimeout time.Duration
LogFormat LogFormat
LogLevel logrus.Level
MaxEventsLimit uint
Expand Down
6 changes: 6 additions & 0 deletions cmd/soroban-rpc/internal/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ func (cfg *Config) options() ConfigOptions {
}
},
},
{
Name: "captive-core-timeout",
Usage: "Timeout for configuring and connecting to the specified Stellar Core instance",
ConfigKey: &cfg.CaptiveCoreTimeout,
DefaultValue: 1 * time.Minute,
},
{
Name: "history-archive-urls",
Usage: "comma-separated list of stellar history archives to connect with",
Expand Down
3 changes: 3 additions & 0 deletions cmd/soroban-rpc/internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ func newCaptiveCore(cfg *config.Config, logger *supportlog.Entry) (*ledgerbacken
logger.WithError(err).Fatal("Invalid captive core toml")
}

newCaptiveCoreCtx, cancelNewCaptiveCore := context.WithTimeout(context.Background(), cfg.CaptiveCoreTimeout)
defer cancelNewCaptiveCore()
captiveConfig := ledgerbackend.CaptiveCoreConfig{
BinaryPath: cfg.StellarCoreBinaryPath,
StoragePath: cfg.CaptiveCoreStoragePath,
Expand All @@ -123,6 +125,7 @@ func newCaptiveCore(cfg *config.Config, logger *supportlog.Entry) (*ledgerbacken
Toml: captiveCoreToml,
UserAgent: "captivecore",
UseDB: true,
Context: newCaptiveCoreCtx,
}
return ledgerbackend.NewCaptive(captiveConfig)

Expand Down

0 comments on commit 0068aca

Please sign in to comment.