settings

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 24 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(1e7),
		SectorAccessPrice: types.Siacoins(1).Div64(1e7),

		Collateral:    types.Siacoins(100).Div64(1 << 40).Div64(blocksPerMonth),
		MaxCollateral: types.Siacoins(1000),

		MinStoragePrice: types.Siacoins(50).Div64(1 << 40).Div64(blocksPerMonth),
		MinEgressPrice:  types.Siacoins(250).Div64(1 << 40),
		MinIngressPrice: 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 ChainManager

type ChainManager interface {
	TipState() consensus.State
}

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(dir string, hostKey types.PrivateKey, rhp2Addr string, store Store, cm ChainManager, tp TransactionPool, w Wallet, log *zap.Logger) (*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 is a no-op

func (*ConfigManager) DiscoveredRHP2Address

func (m *ConfigManager) DiscoveredRHP2Address() string

DiscoveredRHP2Address returns the rhp2 address that was discovered by the gateway

func (*ConfigManager) RHP3TLSConfig

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

RHP3TLSConfig returns the TLS config for the rhp3 WebSocket listener

func (*ConfigManager) Settings

func (m *ConfigManager) Settings() Settings

Settings returns the host's current settings.

func (*ConfigManager) UpdateDynDNS

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

UpdateDynDNS 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 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"`

	Collateral    types.Currency `json:"collateral"`
	MaxCollateral types.Currency `json:"maxCollateral"`

	MinStoragePrice types.Currency `json:"minStoragePrice"`
	MinEgressPrice  types.Currency `json:"minEgressPrice"`
	MinIngressPrice types.Currency `json:"minIngressPrice"`

	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
	DynDNS DNSSettings `json:"dynDNS"`

	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
}

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

Jump to

Keyboard shortcuts

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