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 ¶
const ( DefaultScanSleep = 2*time.Hour + 18*time.Minute MaxScanSleep = 6 * time.Hour MinScanSleep = 1 * time.Hour MaxActiveHosts = 500 InactiveHostCheckupQuantity = 250 )
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 ( MaxReliability = types.NewCurrency64(50) // Given the scanning defaults, about 1 week of survival. DefaultReliability = types.NewCurrency64(20) // Given the scanning defaults, about 3 days 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 returns a host database that will still crawling the hosts it finds on the 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.