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

ingest: Allow enabling Captive Core's fast HTTP server #5586

Merged
merged 7 commits into from
Feb 5, 2025
Merged
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions ingest/ledgerbackend/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ type captiveCoreTomlValues struct {
EnableDiagnosticsForTxSubmission *bool `toml:"ENABLE_DIAGNOSTICS_FOR_TX_SUBMISSION,omitempty"`
EnableEmitSorobanTransactionMetaExtV1 *bool `toml:"EMIT_SOROBAN_TRANSACTION_META_EXT_V1,omitempty"`
EnableEmitLedgerCloseMetaExtV1 *bool `toml:"EMIT_LEDGER_CLOSE_META_EXT_V1,omitempty"`
HTTPQueryPort *uint `toml:"HTTP_QUERY_PORT,omitempty"`
QueryThreadPoolSize *uint `toml:"QUERY_THREADPOOL_SIZE,omitempty"`
QuerySnapshotLedgers *uint `toml:"QUERY_SNAPSHOT_LEDGERS,omitempty"`
}

// QuorumSetIsConfigured returns true if there is a quorum set defined in the configuration.
Expand Down Expand Up @@ -321,6 +324,12 @@ func (c *CaptiveCoreToml) unmarshal(data []byte, strict bool) error {
return nil
}

type FastHTTPServerParams struct {
Port uint16
ThreadPoolSize uint16
SnapshotLedgers uint16
}

// CaptiveCoreTomlParams defines captive core configuration provided by Horizon flags.
type CaptiveCoreTomlParams struct {
// NetworkPassphrase is the Stellar network passphrase used by captive core when connecting to the Stellar network.
Expand All @@ -346,6 +355,8 @@ type CaptiveCoreTomlParams struct {
EnforceSorobanDiagnosticEvents bool
// Enfore EnableSorobanTransactionMetaExtV1 when not disabled explicitly
EnforceSorobanTransactionMetaExtV1 bool
// Enable the Fast HTTP server with these parameters
FastHTTPServerParams *FastHTTPServerParams
}

// NewCaptiveCoreTomlFromFile constructs a new CaptiveCoreToml instance by merging configuration
Expand Down Expand Up @@ -498,6 +509,15 @@ func (c *CaptiveCoreToml) setDefaults(params CaptiveCoreTomlParams) {
if params.EnforceSorobanTransactionMetaExtV1 {
enforceOption(&c.EnableEmitSorobanTransactionMetaExtV1)
}

if params.FastHTTPServerParams != nil {
port := uint(params.FastHTTPServerParams.Port)
c.HTTPQueryPort = &port
ledgers := uint(params.FastHTTPServerParams.SnapshotLedgers)
c.QuerySnapshotLedgers = &ledgers
poolSize := uint(params.FastHTTPServerParams.ThreadPoolSize)
c.QueryThreadPoolSize = &poolSize
}
}

func enforceOption(opt **bool) {
Expand Down
Loading