Documentation ¶
Index ¶
- Constants
- Variables
- type Alerts
- type Announcement
- type ChainManager
- type CloudflareSettings
- type ConfigManager
- func (m *ConfigManager) AcceptingContracts() bool
- func (m *ConfigManager) Announce() error
- func (m *ConfigManager) Close() error
- func (m *ConfigManager) LastAnnouncement() (Announcement, error)
- func (m *ConfigManager) ProcessActions(index types.ChainIndex) error
- func (m *ConfigManager) RHP2Settings() (proto2.HostSettings, error)
- func (m *ConfigManager) RHP3PriceTable() (proto3.HostPriceTable, error)
- func (m *ConfigManager) RHPBandwidthLimiters() (ingress, egress *rate.Limiter)
- func (m *ConfigManager) ScanHeight() uint64
- func (m *ConfigManager) Settings() Settings
- func (cm *ConfigManager) UpdateChainState(tx UpdateStateTx, reverted []chain.RevertUpdate, applied []chain.ApplyUpdate) error
- func (m *ConfigManager) UpdateDDNS(force bool) error
- func (m *ConfigManager) UpdateSettings(s Settings) error
- type DNSSettings
- type DuckDNSSettings
- type NoIPSettings
- type Option
- type Route53Settings
- type Settings
- type Storage
- type Store
- type Syncer
- type UpdateStateTx
- type Wallet
Constants ¶
const ( DNSProviderCloudflare = "cloudflare" DNSProviderDuckDNS = "duckdns" DNSProviderNoIP = "noip" DNSProviderRoute53 = "route53" )
defines DNS providers
Variables ¶
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 Announcement ¶
type Announcement struct { Index types.ChainIndex `json:"index"` Address string `json:"address"` }
An Announcement contains the host's announced netaddress
type ChainManager ¶
type ChainManager interface { Tip() types.ChainIndex TipState() consensus.State BestIndex(height uint64) (types.ChainIndex, bool) RecommendedFee() types.Currency UnconfirmedParents(txn types.Transaction) []types.Transaction AddPoolTransactions([]types.Transaction) (known bool, err error) PoolTransactions() []types.Transaction V2PoolTransactions() []types.V2Transaction V2TransactionSet(types.ChainIndex, types.V2Transaction) (types.ChainIndex, []types.V2Transaction, error) AddV2PoolTransactions(types.ChainIndex, []types.V2Transaction) (known bool, err error) }
ChainManager defines the interface required by the contract manager to interact with the consensus set.
type CloudflareSettings ¶
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(hostKey types.PrivateKey, store Store, cm ChainManager, s Syncer, sm Storage, wm Wallet, opts ...Option) (*ConfigManager, error)
NewConfigManager initializes a new config manager
func (*ConfigManager) AcceptingContracts ¶
func (m *ConfigManager) AcceptingContracts() bool
AcceptingContracts returns true if the host is currently accepting contracts
func (*ConfigManager) Announce ¶
func (m *ConfigManager) Announce() error
Announce announces the host to the network
func (*ConfigManager) LastAnnouncement ¶
func (m *ConfigManager) LastAnnouncement() (Announcement, error)
LastAnnouncement returns the last announcement that was made by the host
func (*ConfigManager) ProcessActions ¶
func (m *ConfigManager) ProcessActions(index types.ChainIndex) error
ProcessActions processes announcement actions based on the given chain index.
func (*ConfigManager) RHP2Settings ¶
func (m *ConfigManager) RHP2Settings() (proto2.HostSettings, error)
RHP2Settings returns the host's current RHP2 settings
func (*ConfigManager) RHP3PriceTable ¶
func (m *ConfigManager) RHP3PriceTable() (proto3.HostPriceTable, error)
RHP3PriceTable returns the host's current RHP3 price table
func (*ConfigManager) RHPBandwidthLimiters ¶
func (m *ConfigManager) RHPBandwidthLimiters() (ingress, egress *rate.Limiter)
RHPBandwidthLimiters returns the rate limiters for all RHP traffic
func (*ConfigManager) ScanHeight ¶
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) UpdateChainState ¶
func (cm *ConfigManager) UpdateChainState(tx UpdateStateTx, reverted []chain.RevertUpdate, applied []chain.ApplyUpdate) error
UpdateChainState updates the host's announcement state based on the given chain updates.
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 ¶
NoIPSettings contains the settings for the No-IP DNS provider.
type Option ¶
type Option func(*ConfigManager)
An Option is a functional option that can be used to configure a config manager.
func WithAlertManager ¶
WithAlertManager sets the alerts manager for the settings manager.
func WithAnnounceInterval ¶
WithAnnounceInterval sets the interval at which the host should re-announce itself.
func WithInitialSettings ¶
WithInitialSettings sets the host's settings when the config manager is initialized. If this option is not provided, the default settings are used. If the database already contains settings, they will be used.
func WithRHP3Port ¶
WithRHP3Port sets the port that the host is listening for RHP3 connections on. This is part of the RHP2 settings.
func WithValidateNetAddress ¶
WithValidateNetAddress sets whether the settings manager should validate the announced net address.
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) // LastV2AnnouncementHash returns the hash of the last v2 announcement. LastV2AnnouncementHash() (types.Hash256, types.ChainIndex, error) }
A Store persists the host's settings
type Syncer ¶
type Syncer interface { BroadcastTransactionSet([]types.Transaction) BroadcastV2TransactionSet(types.ChainIndex, []types.V2Transaction) }
A Syncer broadcasts transactions to its peers
type UpdateStateTx ¶
type UpdateStateTx interface { LastAnnouncement() (Announcement, error) RevertLastAnnouncement() error SetLastAnnouncement(Announcement) error // LastV2AnnouncementHash returns the hash of the last v2 announcement. LastV2AnnouncementHash() (types.Hash256, types.ChainIndex, error) // RevertLastV2Announcement reverts the last v2 announcement. RevertLastV2Announcement() error // SetLastV2Announcement sets the last v2 announcement. SetLastV2AnnouncementHash(types.Hash256, types.ChainIndex) error }
An UpdateStateTx is a transaction that can update the host's announcement state.
type Wallet ¶
type Wallet interface { Address() types.Address ReleaseInputs(txns []types.Transaction, v2txns []types.V2Transaction) FundTransaction(txn *types.Transaction, amount types.Currency, useUnconfirmed bool) ([]types.Hash256, error) SignTransaction(txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields) FundV2Transaction(txn *types.V2Transaction, amount types.Currency, useUnconfirmed bool) (types.ChainIndex, []int, error) SignV2Inputs(txn *types.V2Transaction, toSign []int) }
A Wallet manages Siacoins and funds transactions