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) InsertHost(host modules.HostSettings) error
- func (hdb *HostDB) ProcessConsensusChange(cc modules.ConsensusChange)
- func (hdb *HostDB) RandomHosts(count int) (hosts []modules.HostSettings)
- func (hdb *HostDB) RemoveHost(addr modules.NetAddress) error
Constants ¶
Variables ¶
var ( MaxReliability = types.NewCurrency64(225) // Given the scanning defaults, about 3 weeks of survival. DefaultReliability = types.NewCurrency64(75) // Given the scanning defaults, about 1 week of survival. 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 New ¶
New creates and starts up a hostdb. The hostdb that gets returned will not have finished scanning the network or blockchain.
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) InsertHost ¶ added in v0.3.1
func (hdb *HostDB) InsertHost(host modules.HostSettings) error
InsertHost inserts a host into the database.
func (*HostDB) ProcessConsensusChange ¶
func (hdb *HostDB) ProcessConsensusChange(cc modules.ConsensusChange)
ProcessConsensusChange accepts an update from the consensus set which contains new blocks.
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) RemoveHost ¶ added in v0.3.1
func (hdb *HostDB) RemoveHost(addr modules.NetAddress) error
RemoveHost removes a host from the database.