hostdb

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2015 License: MIT Imports: 12 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 = 15 * time.Hour
	MaxScanSleep     = 20 * time.Hour
	MinScanSleep     = 4 * time.Hour

	MaxActiveHosts              = 200
	InactiveHostCheckupQuantity = 100
)
View Source
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

View Source
var (
	ErrNilGateway      = errors.New("gateway cannot be nil")
	ErrNilConsensusSet = errors.New("consensus set cannot be nil")
)
View Source
var (
	ActiveReliability   = types.NewCurrency64(20)
	InactiveReliability = types.NewCurrency64(10)
	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 *consensus.State, g modules.Gateway) (hdb *HostDB, err error)

New returns an empty HostDatabase.

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) RandomHost

func (hdb *HostDB) RandomHost() (host modules.HostSettings, err error)

RandomHost pulls a random host from the hostdb weighted according to the internal metrics of the hostdb.

func (*HostDB) ReceiveConsensusSetUpdate added in v0.3.1

func (hdb *HostDB) ReceiveConsensusSetUpdate(_, appliedBlocks []types.Block)

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.

Jump to

Keyboard shortcuts

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