Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExchangeRateRetriever ¶
type ExchangeRateRetriever interface {
SiacoinExchangeRate(ctx context.Context, currency string) (float64, error)
}
An ExchangeRateRetriever retrieves the current exchange rate from an external source.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
A Manager manages the host's pinned settings and updates the host's settings based on the current exchange rate.
func NewManager ¶
NewManager creates a new pin manager.
func (*Manager) Pinned ¶
func (m *Manager) Pinned(context.Context) PinnedSettings
Pinned returns the host's pinned settings.
type Option ¶
type Option func(*Manager)
An Option is a functional option for configuring a pin Manager.
func WithAverageRateWindow ¶
WithAverageRateWindow sets the window over which the manager calculates the average exchange rate.
func WithExchangeRateRetriever ¶
func WithExchangeRateRetriever(e ExchangeRateRetriever) Option
WithExchangeRateRetriever sets the exchange rate retriever for the manager.
func WithFrequency ¶
WithFrequency sets the frequency at which the manager updates the host's settings based on the current exchange rate.
func WithLogger ¶
WithLogger sets the logger for the manager.
func WithSettings ¶
func WithSettings(s SettingsManager) Option
WithSettings sets the settings manager for the manager.
type PinnedSettings ¶
type PinnedSettings struct {
// Currency is the external three letter currency code. If empty,
// pinning is disabled. If the explorer does not support the
// currency an error is returned.
Currency string `json:"currency"`
// Threshold is a percentage from 0 to 1 that determines when the
// host's settings are updated based on the current exchange rate.
Threshold float64 `json:"threshold"`
// Storage, Ingress, and Egress are the pinned prices in the
// external currency.
Storage Pin `json:"storage"`
Ingress Pin `json:"ingress"`
Egress Pin `json:"egress"`
// MaxCollateral is the maximum collateral that the host will
// accept in the external currency.
MaxCollateral Pin `json:"maxCollateral"`
}
PinnedSettings contains the settings that can be optionally pinned to an external currency. This uses an external explorer to retrieve the current exchange rate.
type SettingsManager ¶
type SettingsManager interface {
Settings() settings.Settings
UpdateSettings(settings.Settings) error
}
A SettingsManager updates and retrieves the host's settings.
type Store ¶
type Store interface {
PinnedSettings(context.Context) (PinnedSettings, error)
UpdatePinnedSettings(context.Context, PinnedSettings) error
}
A Store stores and retrieves pinned settings.