Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOptions) error
- type App
- func (a *App) Close()
- func (a *App) CloseDB()
- func (a *App) Config() Config
- func (a *App) GetCoreState() corestate.State
- func (a *App) HistoryQ() *history.Q
- func (a *App) HorizonSession() db.SessionInterface
- func (a *App) Paths() paths.Finder
- func (a *App) Serve() error
- func (a *App) Shutdown()
- func (a *App) Tick(ctx context.Context) error
- func (a *App) UpdateCoreLedgerState(ctx context.Context)
- func (a *App) UpdateFeeStatsState(ctx context.Context)
- func (a *App) UpdateHorizonLedgerState(ctx context.Context)
- func (a *App) UpdateStellarCoreInfo(ctx context.Context) error
- type ApplyOptions
- type Config
Constants ¶
const ( // DatabaseURLFlagName is the command line flag for configuring the Horizon postgres URL DatabaseURLFlagName = "db-url" // IngestFlagName is the command line flag for enabling ingestion on the Horizon instance IngestFlagName = "ingest" // StellarCoreDBURLFlagName is the command line flag for configuring the postgres Stellar Core URL StellarCoreDBURLFlagName = "stellar-core-db-url" // StellarCoreURLFlagName is the command line flag for configuring the URL fore Stellar Core HTTP endpoint StellarCoreURLFlagName = "stellar-core-url" // StellarCoreBinaryPathName is the command line flag for configuring the path to the stellar core binary StellarCoreBinaryPathName = "stellar-core-binary-path" // CaptiveCoreConfigPathName is the command line flag for configuring the path to the captive core configuration file CaptiveCoreConfigPathName = "captive-core-config-path" // CaptiveCoreHTTPPortFlagName is the commandline flag for specifying captive core HTTP port CaptiveCoreHTTPPortFlagName = "captive-core-http-port" // EnableCaptiveCoreIngestionFlagName is the commandline flag for enabling captive core ingestion EnableCaptiveCoreIngestionFlagName = "enable-captive-core-ingestion" // NetworkPassphraseFlagName is the command line flag for specifying the network passphrase NetworkPassphraseFlagName = "network-passphrase" // HistoryArchiveURLsFlagName is the command line flag for specifying the history archive URLs HistoryArchiveURLsFlagName = "history-archive-urls" // HistoryArchiveCaching is the flag for controlling whether or not there's // an on-disk cache for history archive downloads HistoryArchiveCachingFlagName = "history-archive-caching" // NetworkFlagName is the command line flag for specifying the "network" NetworkFlagName = "network" // EnableIngestionFilteringFlagName is the command line flag for enabling the experimental ingestion filtering feature (now enabled by default) EnableIngestionFilteringFlagName = "exp-enable-ingestion-filtering" // DisableTxSubFlagName is the command line flag for disabling transaction submission feature of Horizon DisableTxSubFlagName = "disable-tx-sub" // SkipTxmeta is the command line flag for disabling persistence of tx meta in history transaction table SkipTxmeta = "skip-txmeta" // EmitVerboseMeta is the command line flag for enabling all kinds of verbose events - diagnosticEvents, classicEvents during ingestion EmitVerboseMeta = "emit-verbose-meta" // StellarPubnet is a constant representing the Stellar public network StellarPubnet = "pubnet" // StellarTestnet is a constant representing the Stellar test network StellarTestnet = "testnet" // StellarFuturenet is a constant representing the Stellar future network StellarFuturenet = "futurenet" )
Variables ¶
var ( IngestCmd = "ingest" RecordMetricsCmd = "record-metrics" DbCmd = "db" ServeCmd = "serve" HorizonCmd = "horizon" DbFillGapsCmd = "fill-gaps" DbReingestCmd = "reingest" IngestTriggerStateRebuild = "trigger-state-rebuild" IngestBuildStateCmd = "build-state" IngestStressTestCmd = "stress-test" IngestVerifyRangeCmd = "verify-range" ApiServerCommands = []string{HorizonCmd, ServeCmd} IngestionCommands = append(ApiServerCommands, IngestBuildStateCmd, IngestStressTestCmd, IngestVerifyRangeCmd, DbFillGapsCmd, DbReingestCmd) DatabaseBoundCommands = append(ApiServerCommands, DbCmd, IngestCmd) )
Functions ¶
func ApplyFlags ¶
func ApplyFlags(config *Config, flags support.ConfigOptions, options ApplyOptions) error
ApplyFlags applies the command line flags on the given Config instance
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App represents the root of the state of a horizon instance.
func NewAppFromFlags ¶
func NewAppFromFlags(config *Config, flags support.ConfigOptions) (*App, error)
NewAppFromFlags constructs a new Horizon App from the given command line flags
func (*App) Close ¶
func (a *App) Close()
Close cancels the app. It does not close DB connections - use App.CloseDB().
func (*App) CloseDB ¶
func (a *App) CloseDB()
CloseDB closes DB connections. When using during web server shut down make sure all requests are first properly finished to avoid "sql: database is closed" errors.
func (*App) GetCoreState ¶
func (*App) HistoryQ ¶
HistoryQ returns a helper object for performing sql queries against the history portion of horizon's database.
func (*App) HorizonSession ¶
func (a *App) HorizonSession() db.SessionInterface
HorizonSession returns a new session that loads data from the horizon database.
func (*App) Serve ¶
Serve starts the horizon web server, binding it to a socket, setting up the shutdown signals.
func (*App) Tick ¶
Tick triggers horizon to update all of it's background processes such as transaction submission, metrics, ingestion and reaping.
func (*App) UpdateCoreLedgerState ¶
UpdateCoreLedgerState triggers a refresh of Stellar-Core ledger state. This is done separately from Horizon ledger state update to prevent issues in case Stellar-Core query timeout.
func (*App) UpdateFeeStatsState ¶
UpdateFeeStatsState triggers a refresh of several operation fee metrics.
func (*App) UpdateHorizonLedgerState ¶
UpdateHorizonLedgerState triggers a refresh of Horizon ledger state. This is done separately from Core ledger state update to prevent issues in case Stellar-Core query timeout.
func (*App) UpdateStellarCoreInfo ¶
UpdateStellarCoreInfo updates the value of CoreVersion, CurrentProtocolVersion, and CoreSupportedProtocolVersion from the Stellar core API.
Warning: This method should only return an error if it is fatal. See usage in `App.Tick`
type ApplyOptions ¶
type Config ¶
type Config struct {
DatabaseURL string
RoDatabaseURL string
HistoryArchiveURLs []string
Port uint
AdminPort uint
CaptiveCoreBinaryPath string
CaptiveCoreConfigPath string
CaptiveCoreTomlParams ledgerbackend.CaptiveCoreTomlParams
CaptiveCoreToml *ledgerbackend.CaptiveCoreToml
CaptiveCoreStoragePath string
CaptiveCoreReuseStoragePath bool
HistoryArchiveCaching bool
StellarCoreURL string
// MaxDBConnections has a priority over all 4 values below.
MaxDBConnections int
HorizonDBMaxOpenConnections int
HorizonDBMaxIdleConnections int
SSEUpdateFrequency time.Duration
ConnectionTimeout time.Duration
ClientQueryTimeout time.Duration
// MaxHTTPRequestSize is the maximum allowed request payload size
MaxHTTPRequestSize uint
RateQuota *throttled.RateQuota
MaxConcurrentRequests uint
FriendbotURL *url.URL
LogLevel logrus.Level
LogFile string
// MaxPathLength is the maximum length of the path returned by `/paths` endpoint.
MaxPathLength uint
// MaxAssetsPerPathRequest is the maximum number of assets considered for `/paths/strict-send` and `/paths/strict-receive`
MaxAssetsPerPathRequest int
// DisablePoolPathFinding configures horizon to run path finding without including liquidity pools
// in the path finding search.
DisablePoolPathFinding bool
// DisablePathFinding configures horizon without the path finding endpoint.
DisablePathFinding bool
// MaxPathFindingRequests is the maximum number of path finding requests horizon will allow
// in a 1-second period. A value of 0 disables the limit.
MaxPathFindingRequests uint
NetworkPassphrase string
SentryDSN string
LogglyToken string
LogglyTag string
// TLSCert is a path to a certificate file to use for horizon's TLS config
TLSCert string
// TLSKey is the path to a private key file to use for horizon's TLS config
TLSKey string
// Ingest toggles whether this horizon instance should run the data ingestion subsystem.
Ingest bool
// HistoryRetentionCount represents the minimum number of ledgers worth of
// history data to retain in the horizon database. For the purposes of
// determining a "retention duration", each ledger roughly corresponds to 10
// seconds of real time.
HistoryRetentionCount uint
// HistoryRetentionReapCount is the number of ledgers worth of history data
// to remove per second from the Horizon database. It is intended to allow
// control over the amount of CPU and database load caused by reaping,
// especially if enabling reaping for the first time or in times of
// increased ledger load.
HistoryRetentionReapCount uint
// ReapFrequency configures how often (in units of ledgers) history is reaped.
// If ReapFrequency is set to 1 history is reaped after ingesting every ledger.
// If ReapFrequency is set to 2 history is reaped after ingesting every two ledgers.
// etc...
ReapFrequency uint
// ReapLookupTables enables the reaping of history lookup tables
ReapLookupTables bool
// StaleThreshold represents the number of ledgers a history database may be
// out-of-date by before horizon begins to respond with an error to history
// requests.
StaleThreshold uint
// IngestDisableStateVerification disables state verification
// `System.verifyState()` when set to `true`.
IngestDisableStateVerification bool
// IngestStateVerificationCheckpointFrequency configures how often state verification is performed.
// If IngestStateVerificationCheckpointFrequency is set to 1 state verification is run on every checkpoint,
// If IngestStateVerificationCheckpointFrequency is set to 2 state verification is run on every second checkpoint,
// etc...
IngestStateVerificationCheckpointFrequency uint
// IngestStateVerificationTimeout configures a timeout on the state verification routine.
// If IngestStateVerificationTimeout is set to 0 the timeout is disabled.
IngestStateVerificationTimeout time.Duration
// IngestEnableExtendedLogLedgerStats enables extended ledger stats in
// logging.
IngestEnableExtendedLogLedgerStats bool
// IngestSkipProtocolVersionCheck skips protocol version verification during
// ingestion.
IngestSkipProtocolVersionCheck bool
// ApplyMigrations will apply pending migrations to the horizon database
// before starting the horizon service
ApplyMigrations bool
// CheckpointFrequency establishes how many ledgers exist between checkpoints
CheckpointFrequency uint32
// BehindCloudflare determines if Horizon instance is behind Cloudflare. In
// such case http.Request.RemoteAddr will be replaced with Cloudflare header.
BehindCloudflare bool
// BehindAWSLoadBalancer determines if Horizon instance is behind AWS load
// balances like ELB or ALB. In such case http.Request.RemoteAddr will be
// replaced with the last IP in X-Forwarded-For header.
BehindAWSLoadBalancer bool
// RoundingSlippageFilter excludes trades from /trade_aggregations with rounding slippage >x bps
RoundingSlippageFilter int
// Stellar network: 'testnet' or 'pubnet'
Network string
// DisableTxSub disables transaction submission functionality for Horizon.
DisableTxSub bool
// SkipTxmeta, when enabled, will not store meta xdr in history transaction table
SkipTxmeta bool
// EmitVerboseMeta, when enabled will include all kinds of events in txMeta - diagnosticEvents/classicEvents
// SkipTxMeta and EmitVerboseMeta dont go hand in hand. i.e EmitVerboseMeta cannot be TRUE if SkipTxMeta is set to TRUE
EmitVerboseMeta bool
}
Config is the configuration for horizon. It gets populated by the app's main function and is provided to NewApp.
func Flags ¶
func Flags() (*Config, support.ConfigOptions)
Flags returns a Config instance and a list of commandline flags which modify the Config instance
Directories
¶
| Path | Synopsis |
|---|---|
|
Package actions provides the infrastructure for defining and executing actions (code that is triggered in response to an client request) on horizon.
|
Package actions provides the infrastructure for defining and executing actions (code that is triggered in response to an client request) on horizon. |
|
Package assets is a simple helper package to help convert to/from xdr.AssetType values
|
Package assets is a simple helper package to help convert to/from xdr.AssetType values |
|
Package codes is a helper package to help convert to transaction and operation result codes to strings used in horizon.
|
Package codes is a helper package to help convert to transaction and operation result codes to strings used in horizon. |
|
Package db2 is the replacement for db.
|
Package db2 is the replacement for db. |
|
history
Package history contains database record definitions useable for reading rows from a the history portion of horizon's database
|
Package history contains database record definitions useable for reading rows from a the history portion of horizon's database |
|
Package hchi provides functions to support embedded and retrieving a request id from a go context tree
|
Package hchi provides functions to support embedded and retrieving a request id from a go context tree |
|
Package ingest contains the new ingestion system for horizon.
|
Package ingest contains the new ingestion system for horizon. |
|
Package ledger provides useful utilities concerning ledgers within stellar, specifically as a central location to store a cached snapshot of the state of both horizon's and stellar-core's views of the ledger.
|
Package ledger provides useful utilities concerning ledgers within stellar, specifically as a central location to store a cached snapshot of the state of both horizon's and stellar-core's views of the ledger. |
|
Package operationfeestats provides useful utilities concerning operation fee stats within stellar,specifically as a central location to store a cached snapshot of the state of network per operation fees and surge pricing.
|
Package operationfeestats provides useful utilities concerning operation fee stats within stellar,specifically as a central location to store a cached snapshot of the state of network per operation fees and surge pricing. |
|
Package paths provides utilities and facilities for payment paths as needed by horizon.
|
Package paths provides utilities and facilities for payment paths as needed by horizon. |
|
sse
This package contains the Server Sent Events implementation used by horizon.
|
This package contains the Server Sent Events implementation used by horizon. |
|
build_release_artifacts
command
|
|
|
Package simplepath provides an implementation of paths.
|
Package simplepath provides an implementation of paths. |
|
Package test contains simple test helpers that should not have any dependencies on horizon's packages.
|
Package test contains simple test helpers that should not have any dependencies on horizon's packages. |
|
db
Package db provides helpers to connect to test databases.
|
Package db provides helpers to connect to test databases. |
|
transactions
Package transactions offers common infrastructure for testing Transactions
|
Package transactions offers common infrastructure for testing Transactions |
|
Package txsub provides the machinery that horizon uses to submit transactions to the stellar network and track their progress.
|
Package txsub provides the machinery that horizon uses to submit transactions to the stellar network and track their progress. |
|
Package utf8 contains utilities for working with utf8 data.
|
Package utf8 contains utilities for working with utf8 data. |