hostdb

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2018 License: MIT Imports: 19 Imported by: 6

Documentation

Overview

Package hostdb provides a HostDB object that implements the renter.hostDB interface. The blockchain is scanned for host announcements and hosts that are found get added to the host database. The database continually scans the set of hosts it has found and updates who is online.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInitialScanIncomplete is returned whenever an operation is not
	// allowed to be executed before the initial host scan has finished.
	ErrInitialScanIncomplete = errors.New("initial hostdb scan is not yet completed")
)

Functions

This section is empty.

Types

type HostDB

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

The HostDB is a database of potential hosts. It assigns a weight to each host based on their hosting parameters, and then can select hosts at random for uploading files.

func New

func New(g modules.Gateway, cs modules.ConsensusSet, persistDir string) (*HostDB, error)

New returns a new HostDB.

func NewCustomHostDB added in v1.3.3

func NewCustomHostDB(g modules.Gateway, cs modules.ConsensusSet, persistDir string, deps modules.Dependencies) (*HostDB, error)

NewCustomHostDB creates a HostDB using the provided dependencies. It loads the old persistence data, spawns the HostDB's scanning threads, and subscribes it to the consensusSet.

func (*HostDB) ActiveHosts

func (hdb *HostDB) ActiveHosts() (activeHosts []modules.HostDBEntry)

ActiveHosts returns a list of hosts that are currently online, sorted by weight.

func (*HostDB) AllHosts

func (hdb *HostDB) AllHosts() (allHosts []modules.HostDBEntry)

AllHosts returns all of the hosts known to the hostdb, including the inactive ones.

func (*HostDB) AverageContractPrice added in v1.0.1

func (hdb *HostDB) AverageContractPrice() (totalPrice types.Currency)

AverageContractPrice returns the average price of a host.

func (*HostDB) Close

func (hdb *HostDB) Close() error

Close closes the hostdb, terminating its scanning threads

func (*HostDB) EstimateHostScore added in v1.3.0

func (hdb *HostDB) EstimateHostScore(entry modules.HostDBEntry) modules.HostScoreBreakdown

EstimateHostScore takes a HostExternalSettings and returns the estimated score of that host in the hostdb, assuming no penalties for age or uptime.

func (*HostDB) Host

func (hdb *HostDB) Host(spk types.SiaPublicKey) (modules.HostDBEntry, bool)

Host returns the HostSettings associated with the specified NetAddress. If no matching host is found, Host returns false.

func (*HostDB) IncrementFailedInteractions added in v1.3.0

func (hdb *HostDB) IncrementFailedInteractions(key types.SiaPublicKey)

IncrementFailedInteractions increments the number of failed interactions with a host for a given key

func (*HostDB) IncrementSuccessfulInteractions added in v1.3.0

func (hdb *HostDB) IncrementSuccessfulInteractions(key types.SiaPublicKey)

IncrementSuccessfulInteractions increments the number of successful interactions with a host for a given key

func (*HostDB) InitialScanComplete added in v1.3.3

func (hdb *HostDB) InitialScanComplete() (complete bool, err error)

InitialScanComplete returns a boolean indicating if the initial scan of the hostdb is completed.

func (*HostDB) ProcessConsensusChange

func (hdb *HostDB) ProcessConsensusChange(cc modules.ConsensusChange)

ProcessConsensusChange will be called by the consensus set every time there is a change in the blockchain. Updates will always be called in order.

func (*HostDB) RandomHosts

func (hdb *HostDB) RandomHosts(n int, excludeKeys []types.SiaPublicKey) ([]modules.HostDBEntry, error)

RandomHosts implements the HostDB interface's RandomHosts() method. It takes a number of hosts to return, and a slice of netaddresses to ignore, and returns a slice of entries.

func (*HostDB) ScoreBreakdown added in v1.1.1

func (hdb *HostDB) ScoreBreakdown(entry modules.HostDBEntry) modules.HostScoreBreakdown

ScoreBreakdown provdes a detailed set of scalars and bools indicating elements of the host's overall score.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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