hostdb

package
v0.4.2-beta Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2015 License: MIT Imports: 13 Imported by: 0

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

View Source
const (
	DefaultScanSleep = 1*time.Hour + 37*time.Minute
	MaxScanSleep     = 4 * time.Hour
	MinScanSleep     = 1 * time.Hour

	MaxActiveHosts              = 500
	InactiveHostCheckupQuantity = 250
)

Variables

View Source
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)
)
View Source
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

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

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.

Jump to

Keyboard shortcuts

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