frontier

package
v0.0.0-...-55f7a6b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DatabaseURLFlagName is the command line flag for configuring the Frontier postgres URL
	DatabaseURLFlagName = "db-url"
	// DigitalBitsCoreDBURLFlagName is the command line flag for configuring the postgres DigitalBits Core URL
	DigitalBitsCoreDBURLFlagName = "digitalbits-core-db-url"
	// DigitalBitsCoreURLFlagName is the command line flag for configuring the URL fore DigitalBits Core HTTP endpoint
	DigitalBitsCoreURLFlagName = "digitalbits-core-url"
	// DigitalBitsCoreBinaryPathName is the command line flag for configuring the path to the digitalbits core binary
	DigitalBitsCoreBinaryPathName = "digitalbits-core-binary-path"

	// CaptiveCoreConfigPathName is the command line flag for configuring the path to the captive core configuration file
	CaptiveCoreConfigPathName = "captive-core-config-path"
	// captive-core-use-db is the command line flag for enabling captive core runtime to use an external db url connection rather than RAM for ledger states
	CaptiveCoreConfigUseDB = "captive-core-use-db"
)

Variables

This section is empty.

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 frontier instance.

func NewApp

func NewApp(config Config) (*App, error)

NewApp constructs an new App instance from the provided config.

func NewAppFromFlags

func NewAppFromFlags(config *Config, flags support.ConfigOptions) (*App, error)

NewAppFromFlags constructs a new Frontier 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) Config

func (a *App) Config() Config

func (*App) DeleteUnretainedHistory

func (a *App) DeleteUnretainedHistory(ctx context.Context) error

DeleteUnretainedHistory forwards to the app's reaper. See `reap.DeleteUnretainedHistory` for details

func (*App) FrontierSession

func (a *App) FrontierSession() db.SessionInterface

FrontierSession returns a new session that loads data from the frontier database.

func (*App) GetCoreState

func (a *App) GetCoreState() corestate.State

func (*App) HistoryQ

func (a *App) HistoryQ() *history.Q

HistoryQ returns a helper object for performing sql queries against the history portion of frontier's database.

func (*App) Paths

func (a *App) Paths() paths.Finder

Paths returns the paths.Finder instance used by frontier

func (*App) Serve

func (a *App) Serve() error

Serve starts the frontier web server, binding it to a socket, setting up the shutdown signals.

func (*App) Tick

func (a *App) Tick(ctx context.Context) error

Tick triggers frontier to update all of it's background processes such as transaction submission, metrics, ingestion and reaping.

func (*App) UpdateCoreLedgerState

func (a *App) UpdateCoreLedgerState(ctx context.Context)

UpdateCoreLedgerState triggers a refresh of DigitalBits-Core ledger state. This is done separately from Frontier ledger state update to prevent issues in case DigitalBits-Core query timeout.

func (*App) UpdateDigitalBitsCoreInfo

func (a *App) UpdateDigitalBitsCoreInfo(ctx context.Context) error

UpdateDigitalBitsCoreInfo updates the value of CoreVersion, CurrentProtocolVersion, and CoreSupportedProtocolVersion from the DigitalBits core API.

Warning: This method should only return an error if it is fatal. See usage in `App.Tick`

func (*App) UpdateFeeStatsState

func (a *App) UpdateFeeStatsState(ctx context.Context)

UpdateFeeStatsState triggers a refresh of several operation fee metrics.

func (*App) UpdateFrontierLedgerState

func (a *App) UpdateFrontierLedgerState(ctx context.Context)

UpdateFrontierLedgerState triggers a refresh of Frontier ledger state. This is done separately from Core ledger state update to prevent issues in case DigitalBits-Core query timeout.

type ApplyOptions

type ApplyOptions struct {
	AlwaysIngest             bool
	RequireCaptiveCoreConfig bool
}

type Config

type Config struct {
	DatabaseURL        string
	RoDatabaseURL      string
	HistoryArchiveURLs []string
	Port               uint
	AdminPort          uint

	EnableCaptiveCoreIngestion  bool
	EnableIngestionFiltering    bool
	UsingDefaultPubnetConfig    bool
	CaptiveCoreBinaryPath       string
	RemoteCaptiveCoreURL        string
	CaptiveCoreConfigPath       string
	CaptiveCoreTomlParams       ledgerbackend.CaptiveCoreTomlParams
	CaptiveCoreToml             *ledgerbackend.CaptiveCoreToml
	CaptiveCoreStoragePath      string
	CaptiveCoreReuseStoragePath bool
	CaptiveCoreConfigUseDB      bool

	DigitalBitsCoreDatabaseURL string
	DigitalBitsCoreURL         string

	// MaxDBConnections has a priority over all 4 values below.
	MaxDBConnections             int
	FrontierDBMaxOpenConnections int
	FrontierDBMaxIdleConnections int

	SSEUpdateFrequency time.Duration
	ConnectionTimeout  time.Duration
	RateQuota          *throttled.RateQuota
	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-recieve`
	MaxAssetsPerPathRequest int
	// DisablePoolPathFinding configures frontier to run path finding without including liquidity pools
	// in the path finding search.
	DisablePoolPathFinding bool
	// DisablePathFinding configures frontier without the path finding endpoint.
	DisablePathFinding bool
	// MaxPathFindingRequests is the maximum number of path finding requests frontier 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 frontier's TLS config
	TLSCert string
	// TLSKey is the path to a private key file to use for frontier's TLS config
	TLSKey string
	// Ingest toggles whether this frontier instance should run the data ingestion subsystem.
	Ingest bool
	// CursorName is the cursor used for ingesting from digitalbits-core.
	// Setting multiple cursors in different Frontier instances allows multiple
	// Frontiers to ingest from the same digitalbits-core instance without cursor
	// collisions.
	CursorName string
	// HistoryRetentionCount represents the minimum number of ledgers worth of
	// history data to retain in the frontier database. For the purposes of
	// determining a "retention duration", each ledger roughly corresponds to 10
	// seconds of real time.
	HistoryRetentionCount uint
	// StaleThreshold represents the number of ledgers a history database may be
	// out-of-date by before frontier begins to respond with an error to history
	// requests.
	StaleThreshold uint
	// SkipCursorUpdate causes the ingestor to skip reporting the "last imported
	// ledger" state to digitalbits-core.
	SkipCursorUpdate bool
	// IngestDisableStateVerification disables state verification
	// `System.verifyState()` when set to `true`.
	IngestDisableStateVerification bool
	// IngestEnableExtendedLogLedgerStats enables extended ledger stats in
	// logging.
	IngestEnableExtendedLogLedgerStats bool
	// ApplyMigrations will apply pending migrations to the frontier database
	// before starting the frontier service
	ApplyMigrations bool
	// CheckpointFrequency establishes how many ledgers exist between checkpoints
	CheckpointFrequency uint32
	// BehindCloudflare determines if Frontier instance is behind Cloudflare. In
	// such case http.Request.RemoteAddr will be replaced with Cloudflare header.
	BehindCloudflare bool
	// BehindAWSLoadBalancer determines if Frontier 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
}

Config is the configuration for frontier. 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 frontier.
Package actions provides the infrastructure for defining and executing actions (code that is triggered in response to an client request) on frontier.
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 frontier.
Package codes is a helper package to help convert to transaction and operation result codes to strings used in frontier.
db2
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 frontier's database
Package history contains database record definitions useable for reading rows from a the history portion of frontier'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 frontier.
Package ingest contains the new ingestion system for frontier.
verify
Package verify provides helpers used for verifying if the ingested data is correct.
Package verify provides helpers used for verifying if the ingested data is correct.
Package ledger provides useful utilities concerning ledgers within digitalbits, specifically as a central location to store a cached snapshot of the state of both frontier's and digitalbits-core's views of the ledger.
Package ledger provides useful utilities concerning ledgers within digitalbits, specifically as a central location to store a cached snapshot of the state of both frontier's and digitalbits-core's views of the ledger.
Package operationfeestats provides useful utilities concerning operation fee stats within digitalbits,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 digitalbits,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 frontier.
Package paths provides utilities and facilities for payment paths as needed by frontier.
Package reap contains the history reaping subsystem for frontier.
Package reap contains the history reaping subsystem for frontier.
sse
This package contains the Server Sent Events implementation used by frontier.
This package contains the Server Sent Events implementation used by frontier.
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 frontier's packages.
Package test contains simple test helpers that should not have any dependencies on frontier'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 frontier uses to submit transactions to the digitalbits network and track their progress.
Package txsub provides the machinery that frontier uses to submit transactions to the digitalbits network and track their progress.
sequence
Package sequence providers helpers to manage sequence numbers on behalf of frontier clients.
Package sequence providers helpers to manage sequence numbers on behalf of frontier clients.
Package utf8 contains utilities for working with utf8 data.
Package utf8 contains utilities for working with utf8 data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL