hostdb

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilState            = errors.New("hostdb can't use nil State")
	ErrMissingGenesisBlock = errors.New("state doesn't have a genesis block")
)

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(s *consensus.State, g modules.Gateway) (hdb *HostDB, err error)

New returns an empty HostDatabase.

func (*HostDB) FlagHost

func (hdb *HostDB) FlagHost(addr modules.NetAddress) error

FlagHost is called when a host is caught misbehaving. In general, the behavior is that the host will be called less often. For the time being, that means removing the host from the database outright.

func (*HostDB) Insert

func (hdb *HostDB) Insert(entry modules.HostEntry) error

Insert attempts to insert a host entry into the database.

func (*HostDB) NumHosts

func (hdb *HostDB) NumHosts() int

NumHosts returns the number of hosts in the active database.

func (*HostDB) RandomHost

func (hdb *HostDB) RandomHost() (h modules.HostEntry, err error)

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

func (*HostDB) Remove

func (hdb *HostDB) Remove(addr modules.NetAddress) error

Remove is the thread-safe version of remove.

Jump to

Keyboard shortcuts

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