autopilot

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 30 Imported by: 1

Documentation

Overview

Copyright (c) 2014-2020 Montana Flynn (https://montanaflynn.com)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountStore

type AccountStore interface {
	Account(ctx context.Context, id rhpv3.Account, hk types.PublicKey) (account api.Account, err error)
	Accounts(ctx context.Context) (accounts []api.Account, err error)
}

type Autopilot

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

func New

func New(id string, bus Bus, workers []Worker, logger *zap.Logger, heartbeat time.Duration, scannerScanInterval time.Duration, scannerBatchSize, scannerNumThreads uint64, migrationHealthCutoff float64, accountsRefillInterval time.Duration, revisionSubmissionBuffer, migratorParallelSlabsPerWorker uint64, revisionBroadcastInterval time.Duration) (*Autopilot, error)

New initializes an Autopilot.

func (*Autopilot) DismissAlert added in v0.7.0

func (ap *Autopilot) DismissAlert(ctx context.Context, ids ...types.Hash256)

func (*Autopilot) Handler

func (ap *Autopilot) Handler() http.Handler

Handler returns an HTTP handler that serves the autopilot api.

func (*Autopilot) HasAlert added in v1.0.6

func (ap *Autopilot) HasAlert(ctx context.Context, id types.Hash256) bool

func (*Autopilot) RegisterAlert added in v0.7.0

func (ap *Autopilot) RegisterAlert(ctx context.Context, a alerts.Alert)

func (*Autopilot) Run

func (ap *Autopilot) Run() error

func (*Autopilot) Shutdown

func (ap *Autopilot) Shutdown(_ context.Context) error

Shutdown shuts down the autopilot.

func (*Autopilot) StartTime

func (ap *Autopilot) StartTime() time.Time

func (*Autopilot) State

func (ap *Autopilot) State() state

func (*Autopilot) Trigger

func (ap *Autopilot) Trigger(forceScan bool) bool

func (*Autopilot) Uptime

func (ap *Autopilot) Uptime() (dur time.Duration)

type Bus

type Bus interface {
	alerts.Alerter
	webhooks.Broadcaster

	// Accounts
	Account(ctx context.Context, id rhpv3.Account, hostKey types.PublicKey) (account api.Account, err error)
	Accounts(ctx context.Context) (accounts []api.Account, err error)

	// Autopilots
	Autopilot(ctx context.Context, id string) (autopilot api.Autopilot, err error)
	UpdateAutopilot(ctx context.Context, autopilot api.Autopilot) error

	// consensus
	ConsensusState(ctx context.Context) (api.ConsensusState, error)

	// contracts
	AddContract(ctx context.Context, c rhpv2.ContractRevision, contractPrice, totalCost types.Currency, startHeight uint64, state string) (api.ContractMetadata, error)
	AddRenewedContract(ctx context.Context, c rhpv2.ContractRevision, contractPrice, totalCost types.Currency, startHeight uint64, renewedFrom types.FileContractID, state string) (api.ContractMetadata, error)
	AncestorContracts(ctx context.Context, id types.FileContractID, minStartHeight uint64) ([]api.ArchivedContract, error)
	ArchiveContracts(ctx context.Context, toArchive map[types.FileContractID]string) error
	Contract(ctx context.Context, id types.FileContractID) (api.ContractMetadata, error)
	Contracts(ctx context.Context, opts api.ContractsOpts) (contracts []api.ContractMetadata, err error)
	FileContractTax(ctx context.Context, payout types.Currency) (types.Currency, error)
	SetContractSet(ctx context.Context, set string, contracts []types.FileContractID) error
	PrunableData(ctx context.Context) (prunableData api.ContractsPrunableDataResponse, err error)

	// hostdb
	Host(ctx context.Context, hostKey types.PublicKey) (hostdb.HostInfo, error)
	Hosts(ctx context.Context, opts api.GetHostsOptions) ([]hostdb.Host, error)
	HostsForScanning(ctx context.Context, opts api.HostsForScanningOptions) ([]hostdb.HostAddress, error)
	RemoveOfflineHosts(ctx context.Context, minRecentScanFailures uint64, maxDowntime time.Duration) (uint64, error)
	SearchHosts(ctx context.Context, opts api.SearchHostOptions) ([]hostdb.Host, error)

	// metrics
	RecordContractSetChurnMetric(ctx context.Context, metrics ...api.ContractSetChurnMetric) error
	RecordContractPruneMetric(ctx context.Context, metrics ...api.ContractPruneMetric) error

	// objects
	ObjectsBySlabKey(ctx context.Context, bucket string, key object.EncryptionKey) (objects []api.ObjectMetadata, err error)
	RefreshHealth(ctx context.Context) error
	Slab(ctx context.Context, key object.EncryptionKey) (object.Slab, error)
	SlabsForMigration(ctx context.Context, healthCutoff float64, set string, limit int) ([]api.UnhealthySlab, error)

	// settings
	UpdateSetting(ctx context.Context, key string, value interface{}) error
	GougingSettings(ctx context.Context) (gs api.GougingSettings, err error)
	RedundancySettings(ctx context.Context) (rs api.RedundancySettings, err error)

	// syncer
	SyncerPeers(ctx context.Context) (resp []string, err error)

	// txpool
	RecommendedFee(ctx context.Context) (types.Currency, error)
	TransactionPool(ctx context.Context) (txns []types.Transaction, err error)

	// wallet
	Wallet(ctx context.Context) (api.WalletResponse, error)
	WalletDiscard(ctx context.Context, txn types.Transaction) error
	WalletOutputs(ctx context.Context) (resp []wallet.SiacoinElement, err error)
	WalletPending(ctx context.Context) (resp []types.Transaction, err error)
	WalletRedistribute(ctx context.Context, outputs int, amount types.Currency) (ids []types.TransactionID, err error)
}

type Client

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

A Client provides methods for interacting with an autopilot.

func NewClient

func NewClient(addr, password string) *Client

NewClient returns a new autopilot client.

func (*Client) Config

func (c *Client) Config() (cfg api.AutopilotConfig, err error)

Config returns the autopilot config.

func (*Client) EvaluateConfig added in v1.0.6

EvalutateConfig evaluates an autopilot config using the given gouging and redundancy settings.

func (*Client) HostInfo

func (c *Client) HostInfo(hostKey types.PublicKey) (resp api.HostHandlerResponse, err error)

HostInfo returns information about the host with given host key.

func (*Client) HostInfos

func (c *Client) HostInfos(ctx context.Context, filterMode, usabilityMode string, addressContains string, keyIn []types.PublicKey, offset, limit int) (resp []api.HostHandlerResponse, err error)

HostInfo returns information about all hosts.

func (*Client) State

func (c *Client) State() (state api.AutopilotStateResponse, err error)

State returns the current state of the autopilot.

func (*Client) Trigger

func (c *Client) Trigger(forceScan bool) (_ bool, err error)

Trigger triggers an iteration of the autopilot's main loop.

func (*Client) UpdateConfig

func (c *Client) UpdateConfig(cfg api.AutopilotConfig) error

UpdateConfig updates the autopilot config.

type ContractStore

type ContractStore interface {
	Contracts(ctx context.Context, opts api.ContractsOpts) ([]api.ContractMetadata, error)
}

type Worker

type Worker interface {
	Account(ctx context.Context, hostKey types.PublicKey) (rhpv3.Account, error)
	Contracts(ctx context.Context, hostTimeout time.Duration) (api.ContractsResponse, error)
	ID(ctx context.Context) (string, error)
	MigrateSlab(ctx context.Context, s object.Slab, set string) (api.MigrateSlabResponse, error)

	RHPBroadcast(ctx context.Context, fcid types.FileContractID) (err error)
	RHPForm(ctx context.Context, endHeight uint64, hk types.PublicKey, hostIP string, renterAddress types.Address, renterFunds types.Currency, hostCollateral types.Currency) (rhpv2.ContractRevision, []types.Transaction, error)
	RHPFund(ctx context.Context, contractID types.FileContractID, hostKey types.PublicKey, hostIP, siamuxAddr string, balance types.Currency) (err error)
	RHPPriceTable(ctx context.Context, hostKey types.PublicKey, siamuxAddr string, timeout time.Duration) (hostdb.HostPriceTable, error)
	RHPPruneContract(ctx context.Context, fcid types.FileContractID, timeout time.Duration) (pruned, remaining uint64, err error)
	RHPRenew(ctx context.Context, fcid types.FileContractID, endHeight uint64, hk types.PublicKey, hostIP string, hostAddress, renterAddress types.Address, renterFunds, minNewCollateral types.Currency, expectedStorage, windowSize uint64) (api.RHPRenewResponse, error)
	RHPScan(ctx context.Context, hostKey types.PublicKey, hostIP string, timeout time.Duration) (api.RHPScanResponse, error)
	RHPSync(ctx context.Context, contractID types.FileContractID, hostKey types.PublicKey, hostIP, siamuxAddr string) (err error)
}

Jump to

Keyboard shortcuts

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