settings

package
v1.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 32 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DNSProviderCloudflare = "cloudflare"
	DNSProviderDuckDNS    = "duckdns"
	DNSProviderNoIP       = "noip"
	DNSProviderRoute53    = "route53"
)

defines DNS providers

Variables

View Source
var (
	// DefaultSettings are the default settings for the host
	DefaultSettings = Settings{
		AcceptingContracts:  false,
		NetAddress:          "",
		MaxContractDuration: 6 * blocksPerMonth,

		ContractPrice:     types.Siacoins(1).Div64(5),
		BaseRPCPrice:      types.Siacoins(1).Div64(1e6),
		SectorAccessPrice: types.Siacoins(1).Div64(1e6),

		CollateralMultiplier: 2.0,
		MaxCollateral:        types.Siacoins(1000),

		StoragePrice: types.Siacoins(150).Div64(1 << 40).Div64(blocksPerMonth),
		EgressPrice:  types.Siacoins(500).Div64(1 << 40),
		IngressPrice: types.Siacoins(10).Div64(1 << 40),

		PriceTableValidity: 30 * time.Minute,

		AccountExpiry:     30 * 24 * time.Hour,
		MaxAccountBalance: types.Siacoins(10),
		WindowSize:        144,

		MaxRegistryEntries: 100000,
	}
	// ErrNoSettings must be returned by the store if the host has no settings yet
	ErrNoSettings = errors.New("no settings found")
)

Functions

This section is empty.

Types

type Alerts added in v0.2.2

type Alerts interface {
	Register(alerts.Alert)
}

Alerts registers global alerts.

type Announcement added in v0.2.2

type Announcement struct {
	Index     types.ChainIndex `json:"index"`
	PublicKey types.PublicKey  `json:"publicKey"`
	Address   string           `json:"address"`
}

An Announcement contains the host's announced netaddress and public key

type ChainManager

type ChainManager interface {
	TipState() consensus.State
	Subscribe(s modules.ConsensusSetSubscriber, ccID modules.ConsensusChangeID, cancel <-chan struct{}) error
}

A ChainManager manages the current consensus state

type CloudflareSettings

type CloudflareSettings struct {
	Token  string `json:"token"`
	ZoneID string `json:"zoneID"`
}

CloudflareSettings contains the settings for the Cloudflare DNS provider.

type ConfigManager

type ConfigManager struct {
	// contains filtered or unexported fields
}

A ConfigManager manages the host's current configuration

func NewConfigManager

func NewConfigManager(opts ...Option) (*ConfigManager, error)

NewConfigManager initializes a new config manager

func (*ConfigManager) Announce

func (m *ConfigManager) Announce() error

Announce announces the host to the network

func (*ConfigManager) BandwidthLimiters

func (m *ConfigManager) BandwidthLimiters() (ingress, egress *rate.Limiter)

BandwidthLimiters returns the rate limiters for all traffic

func (*ConfigManager) Close

func (m *ConfigManager) Close() error

Close closes the config manager

func (*ConfigManager) DiscoveredRHP2Address

func (m *ConfigManager) DiscoveredRHP2Address() string

DiscoveredRHP2Address returns the rhp2 address that was discovered by the gateway

func (*ConfigManager) LastAnnouncement added in v0.2.2

func (m *ConfigManager) LastAnnouncement() (Announcement, error)

LastAnnouncement returns the last announcement that was made by the host

func (*ConfigManager) ProcessConsensusChange added in v0.2.2

func (cm *ConfigManager) ProcessConsensusChange(cc modules.ConsensusChange)

ProcessConsensusChange implements modules.ConsensusSetSubscriber.

func (*ConfigManager) RHP3TLSConfig

func (m *ConfigManager) RHP3TLSConfig() *tls.Config

RHP3TLSConfig returns the TLS config for the rhp3 WebSocket listener

func (*ConfigManager) ScanHeight added in v0.2.2

func (m *ConfigManager) ScanHeight() uint64

ScanHeight returns the last block height that was scanned for announcements

func (*ConfigManager) Settings

func (m *ConfigManager) Settings() Settings

Settings returns the host's current settings.

func (*ConfigManager) UpdateDDNS

func (m *ConfigManager) UpdateDDNS(force bool) error

UpdateDDNS triggers an update of the host's dynamic DNS records.

func (*ConfigManager) UpdateSettings

func (m *ConfigManager) UpdateSettings(s Settings) error

UpdateSettings updates the host's settings.

type DNSSettings

type DNSSettings struct {
	Provider string          `json:"provider"`
	IPv4     bool            `json:"ipv4"`
	IPv6     bool            `json:"ipv6"`
	Options  json.RawMessage `json:"options"`
}

DNSSettings contains the settings for the host's dynamic DNS.

type DuckDNSSettings

type DuckDNSSettings struct {
	Token string `json:"token"`
}

DuckDNSSettings contains the settings for the DuckDNS DNS provider.

type NoIPSettings

type NoIPSettings struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

NoIPSettings contains the settings for the No-IP DNS provider.

type Option added in v1.0.4

type Option func(*ConfigManager)

An Option is a functional option that can be used to configure a config manager.

func WithAlertManager added in v1.0.4

func WithAlertManager(am Alerts) Option

WithAlertManager sets the alerts manager for the settings manager.

func WithCertificateFiles added in v1.0.4

func WithCertificateFiles(certFilePath, keyFilePath string) Option

WithCertificateFiles sets the certificate files for the settings manager.

func WithChainManager added in v1.0.4

func WithChainManager(cm ChainManager) Option

WithChainManager sets the chain manager for the settings manager.

func WithHostKey added in v1.0.4

func WithHostKey(pk types.PrivateKey) Option

WithHostKey sets the host key for the settings manager.

func WithLog added in v1.0.4

func WithLog(log *zap.Logger) Option

WithLog sets the logger for the settings manager.

func WithRHP2Addr added in v1.0.4

func WithRHP2Addr(addr string) Option

WithRHP2Addr sets the address of the RHP2 server.

func WithStore added in v1.0.4

func WithStore(s Store) Option

WithStore sets the store for the settings manager.

func WithTransactionPool added in v1.0.4

func WithTransactionPool(tp TransactionPool) Option

WithTransactionPool sets the transaction pool for the settings manager.

func WithWallet added in v1.0.4

func WithWallet(w Wallet) Option

WithWallet sets the wallet for the settings manager.

type Route53Settings

type Route53Settings struct {
	ID     string `json:"id"`
	Secret string `json:"secret"`
	ZoneID string `json:"zoneID"`
}

Route53Settings contains the settings for the Route53 DNS provider.

type Settings

type Settings struct {
	// Host settings
	AcceptingContracts  bool   `json:"acceptingContracts"`
	NetAddress          string `json:"netAddress"`
	MaxContractDuration uint64 `json:"maxContractDuration"`
	WindowSize          uint64 `json:"windowSize"`

	// Pricing
	ContractPrice     types.Currency `json:"contractPrice"`
	BaseRPCPrice      types.Currency `json:"baseRPCPrice"`
	SectorAccessPrice types.Currency `json:"sectorAccessPrice"`

	CollateralMultiplier float64        `json:"collateralMultiplier"`
	MaxCollateral        types.Currency `json:"maxCollateral"`

	StoragePrice types.Currency `json:"storagePrice"`
	EgressPrice  types.Currency `json:"egressPrice"`
	IngressPrice types.Currency `json:"ingressPrice"`

	PriceTableValidity time.Duration `json:"priceTableValidity"`

	// Registry settings
	MaxRegistryEntries uint64 `json:"maxRegistryEntries"`

	// RHP3 settings
	AccountExpiry     time.Duration  `json:"accountExpiry"`
	MaxAccountBalance types.Currency `json:"maxAccountBalance"`

	// Bandwidth limiter settings
	IngressLimit uint64 `json:"ingressLimit"`
	EgressLimit  uint64 `json:"egressLimit"`

	// DNS settings
	DDNS DNSSettings `json:"ddns"`

	SectorCacheSize uint32 `json:"sectorCacheSize"`

	Revision uint64 `json:"revision"`
}

Settings contains configuration options for the host.

type Store

type Store interface {
	// Settings returns the host's current settings. If the host has no
	// settings yet, ErrNoSettings must be returned.
	Settings() (Settings, error)
	// UpdateSettings updates the host's settings.
	UpdateSettings(s Settings) error

	LastAnnouncement() (Announcement, error)
	UpdateLastAnnouncement(Announcement) error
	RevertLastAnnouncement() error

	LastSettingsConsensusChange() (modules.ConsensusChangeID, uint64, error)
}

A Store persists the host's settings

type TransactionPool

type TransactionPool interface {
	AcceptTransactionSet([]types.Transaction) error
	RecommendedFee() types.Currency
}

A TransactionPool broadcasts transactions to the network.

type Wallet

type Wallet interface {
	FundTransaction(txn *types.Transaction, amount types.Currency) ([]types.Hash256, func(), error)
	SignTransaction(cs consensus.State, txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields) error
}

A Wallet manages funds and signs transactions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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