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

soroban-rpc: Add Timeout for Initializing Captive Core #1104

Closed
wants to merge 1 commit into from
Closed
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 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,
stellarsaur marked this conversation as resolved.
Show resolved Hide resolved
}
return ledgerbackend.NewCaptive(captiveConfig)

Expand Down
Loading