Documentation ¶
Overview ¶
package hostdb provides a HostDB object that implements the modules.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
- Variables
- type HostDB
- func (hdb *HostDB) ActiveHosts() (activeHosts []modules.HostSettings)
- func (hdb *HostDB) AllHosts() (allHosts []modules.HostSettings)
- func (hdb *HostDB) HostDBNotify() <-chan struct{}
- func (hdb *HostDB) InsertHost(host modules.HostSettings) error
- func (hdb *HostDB) RandomHosts(count int) (hosts []modules.HostSettings)
- func (hdb *HostDB) ReceiveConsensusSetUpdate(cc modules.ConsensusChange)
- func (hdb *HostDB) RemoveHost(addr modules.NetAddress) error
Constants ¶
const ( DefaultScanSleep = 15 * time.Hour MaxScanSleep = 20 * time.Hour MinScanSleep = 4 * time.Hour MaxActiveHosts = 200 InactiveHostCheckupQuantity = 100 )
const ( // Hosts will not be removed if there are fewer than this many hosts. // Eventually, this number should be in the low thousands. MinHostThreshold = 5 )
Variables ¶
var ( ErrNilGateway = errors.New("gateway cannot be nil") ErrNilConsensusSet = errors.New("consensus set cannot be nil") )
var ( ActiveReliability = types.NewCurrency64(20) InactiveReliability = types.NewCurrency64(10) UnreachablePenalty = types.NewCurrency64(1) )
var (
ErrOverweight = errors.New("requested a too-heavy weight")
)
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 ¶ added in v0.3.1
func (hdb *HostDB) ActiveHosts() (activeHosts []modules.HostSettings)
ActiveHosts returns the hosts that can be randomly selected out of the hostdb.
func (*HostDB) AllHosts ¶ added in v0.3.1
func (hdb *HostDB) AllHosts() (allHosts []modules.HostSettings)
AllHosts returns all of the hosts known to the hostdb, including the inactive ones.
func (*HostDB) HostDBNotify ¶ added in v0.3.1
func (hdb *HostDB) HostDBNotify() <-chan struct{}
HostDBNotify adds a subscriber to the hostdb.
func (*HostDB) InsertHost ¶ added in v0.3.1
func (hdb *HostDB) InsertHost(host modules.HostSettings) error
InsertHost inserts a host into the database.
func (*HostDB) RandomHosts ¶ added in v0.3.3
func (hdb *HostDB) RandomHosts(count int) (hosts []modules.HostSettings)
RandomHosts will pull up to 'num' random hosts from the hostdb. There will be no repeats, but the length of the slice returned may be less than 'num', and may even be 0. The hosts that get returned first have the higher priority.
func (*HostDB) ReceiveConsensusSetUpdate ¶ added in v0.3.1
func (hdb *HostDB) ReceiveConsensusSetUpdate(cc modules.ConsensusChange)
ReceiveConsensusSetUpdate accepts an update from the consensus set which contains new blocks.
func (*HostDB) RemoveHost ¶ added in v0.3.1
func (hdb *HostDB) RemoveHost(addr modules.NetAddress) error
RemoveHost removes a host from the database.