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 ¶
- Variables
- type HostDB
- func (hdb *HostDB) ActiveHosts() (activeHosts []modules.HostDBEntry)
- func (hdb *HostDB) AllHosts() (allHosts []modules.HostDBEntry)
- func (hdb *HostDB) AveragePrice() types.Currency
- func (hdb *HostDB) Close() error
- func (hdb *HostDB) Host(addr modules.NetAddress) (modules.HostDBEntry, bool)
- func (hdb *HostDB) IsOffline(addr modules.NetAddress) bool
- func (hdb *HostDB) ProcessConsensusChange(cc modules.ConsensusChange)
- func (hdb *HostDB) RandomHosts(n int, ignore []modules.NetAddress) (hosts []modules.HostDBEntry)
Constants ¶
This section is empty.
Variables ¶
var ( MaxReliability = types.NewCurrency64(500) // Given the scanning defaults, about 6 weeks of survival. DefaultReliability = types.NewCurrency64(150) // Given the scanning defaults, about 2 week of survival. UnreachablePenalty = types.NewCurrency64(1) )
Reliability is a measure of a host's uptime.
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 (*HostDB) ActiveHosts ¶
func (hdb *HostDB) ActiveHosts() (activeHosts []modules.HostDBEntry)
ActiveHosts returns the hosts that can be randomly selected out of the hostdb, sorted by preference.
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) AveragePrice ¶
AveragePrice returns the average price of a host.
func (*HostDB) Host ¶
func (hdb *HostDB) Host(addr modules.NetAddress) (modules.HostDBEntry, bool)
Host returns the HostSettings associated with the specified NetAddress. If no matching host is found, Host returns false.
func (*HostDB) IsOffline ¶
func (hdb *HostDB) IsOffline(addr modules.NetAddress) bool
IsOffline reports whether a host is offline. If the HostDB has no record of the host, IsOffline will return false.
TODO: Is this behavior that makes sense?
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, ignore []modules.NetAddress) (hosts []modules.HostDBEntry)
RandomHosts will pull up to 'n' random hosts from the hostdb. There will be no repeats, but the length of the slice returned may be less than 'n', and may even be 0. The hosts that get returned first have the higher priority. Hosts specified in 'ignore' will not be considered; pass 'nil' if no blacklist is desired.