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
- Variables
- type HostDB
- func (hdb *HostDB) ActiveHosts() (activeHosts []modules.HostSettings)
- func (hdb *HostDB) AllHosts() (allHosts []modules.HostSettings)
- func (hdb *HostDB) AveragePrice() types.Currency
- func (hdb *HostDB) NewPool(filesize uint64, duration types.BlockHeight) (HostPool, error)
- func (hdb *HostDB) ProcessConsensusChange(cc modules.ConsensusChange)
- func (hdb *HostDB) Renew(fcid types.FileContractID, newEndHeight types.BlockHeight) (types.FileContractID, error)
- type HostPool
- type Uploader
Constants ¶
Variables ¶
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) )
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, wallet modules.Wallet, tpool modules.TransactionPool, 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 ¶
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 ¶
AveragePrice returns the average price of a host.
func (*HostDB) NewPool ¶
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.