hostdb

package
v0.5.2-rc3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2016 License: MIT Imports: 15 Imported by: 6

Documentation

Overview

Package hostdb provides a HostDB object that implements the renter.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 consensusSet, wallet walletShim, tpool transactionPool, persistDir string) (*HostDB, error)

New returns a new HostDB.

func (*HostDB) ActiveHosts

func (hdb *HostDB) ActiveHosts() (activeHosts []modules.HostSettings)

ActiveHosts returns the hosts that can be randomly selected out of the hostdb.

func (*HostDB) AllHosts

func (hdb *HostDB) AllHosts() (allHosts []modules.HostSettings)

AllHosts returns all of the hosts known to the hostdb, including the inactive ones.

func (*HostDB) AveragePrice

func (hdb *HostDB) AveragePrice() types.Currency

AveragePrice returns the average price of a host.

func (*HostDB) IsOffline

func (hdb *HostDB) IsOffline(addr modules.NetAddress) bool

IsOffline reports whether a host is offline. If the HostDB has no record of the host, IsOffline will return false and spawn a goroutine to the scan the host.

func (*HostDB) NewPool

func (hdb *HostDB) NewPool(filesize uint64, duration types.BlockHeight) (HostPool, error)

NewPool returns an empty HostPool, unless the HostDB contains no hosts at all.

func (*HostDB) ProcessConsensusChange

func (hdb *HostDB) ProcessConsensusChange(cc modules.ConsensusChange)

ProcessConsensusChange will be called by the consensus set every time there is a change in the blockchain. Updates will always be called in order.

func (*HostDB) Renew

func (hdb *HostDB) Renew(fcid types.FileContractID, newEndHeight types.BlockHeight) (types.FileContractID, error)

Renew negotiates a new contract for data already stored with a host. It returns the ID of the new contract. This is a blocking call that performs network I/O.

type HostPool

type HostPool interface {
	// UniqueHosts will return up to 'n' unique hosts that are not in 'old'.
	UniqueHosts(n int, old []modules.NetAddress) []Uploader

	// Close terminates all connections in the host pool.
	Close() error
}

A HostPool is a collection of hosts used to upload a file.

type Uploader

type Uploader interface {
	// Upload revises the underlying contract to store the new data. It
	// returns the offset of the data in the stored file.
	Upload(data []byte) (offset uint64, err error)

	// Address returns the address of the host.
	Address() modules.NetAddress

	// ContractID returns the FileContractID of the contract.
	ContractID() types.FileContractID

	// EndHeight returns the height at which the contract ends.
	EndHeight() types.BlockHeight

	// Close terminates the connection to the uploader.
	Close() error
}

An Uploader uploads data to a host.

Jump to

Keyboard shortcuts

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