hostdb

package
v0.19.5 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 11 Imported by: 11

Documentation

Overview

Package hostdb defines types and functions relevant to scanning hosts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostPublicKey

type HostPublicKey string

A HostPublicKey is the public key announced on the blockchain by a host. A HostPublicKey can be assumed to uniquely identify a host. Hosts should always be identified by their public key, since other identifying information (like a host's current IP address) may change at a later time.

The format of a HostPublicKey is:

specifier:keydata

Where specifier identifies the signature scheme used and keydata contains the hex-encoded bytes of the actual key. Currently, all public keys on Sia use the Ed25519 signature scheme, specified as "ed25519".

func HostKeyFromPublicKey added in v0.3.0

func HostKeyFromPublicKey(pk ed25519.PublicKey) HostPublicKey

HostKeyFromPublicKey converts an ed25519.PublicKey to a HostPublicKey.

func HostKeyFromSiaPublicKey added in v0.3.0

func HostKeyFromSiaPublicKey(spk types.SiaPublicKey) HostPublicKey

HostKeyFromSiaPublicKey converts an types.SiaPublicKey to a HostPublicKey.

func (HostPublicKey) Ed25519

func (hpk HostPublicKey) Ed25519() ed25519.PublicKey

Ed25519 returns the HostPublicKey as an ed25519.PublicKey. The returned key is invalid if hpk is not a Ed25519 key.

func (HostPublicKey) Key

func (hpk HostPublicKey) Key() string

Key returns the keydata portion of a HostPublicKey.

func (HostPublicKey) ShortKey

func (hpk HostPublicKey) ShortKey() string

ShortKey returns the keydata portion of a HostPublicKey, truncated to 8 characters. This is 32 bits of entropy, which is sufficient to prevent collisions in typical usage scenarios. A ShortKey is the preferred way to reference a HostPublicKey in user interfaces.

func (HostPublicKey) SiaPublicKey

func (hpk HostPublicKey) SiaPublicKey() (spk types.SiaPublicKey)

SiaPublicKey returns the HostPublicKey as a types.SiaPublicKey.

type HostSettings

type HostSettings struct {
	AcceptingContracts     bool               `json:"acceptingContracts"`
	MaxDownloadBatchSize   uint64             `json:"maxDownloadBatchSize"`
	MaxDuration            types.BlockHeight  `json:"maxDuration"`
	MaxReviseBatchSize     uint64             `json:"maxReviseBatchSize"`
	NetAddress             modules.NetAddress `json:"netAddress"`
	RemainingStorage       uint64             `json:"remainingStorage"`
	SectorSize             uint64             `json:"sectorSize"`
	TotalStorage           uint64             `json:"totalStorage"`
	UnlockHash             types.UnlockHash   `json:"unlockHash"`
	WindowSize             types.BlockHeight  `json:"windowSize"`
	Collateral             types.Currency     `json:"collateral"`
	MaxCollateral          types.Currency     `json:"maxCollateral"`
	BaseRPCPrice           types.Currency     `json:"baseRPCPrice"`
	ContractPrice          types.Currency     `json:"contractPrice"`
	DownloadBandwidthPrice types.Currency     `json:"downloadBandwidthPrice"`
	SectorAccessPrice      types.Currency     `json:"sectorAccessPrice"`
	StoragePrice           types.Currency     `json:"storagePrice"`
	UploadBandwidthPrice   types.Currency     `json:"uploadBandwidthPrice"`
	RevisionNumber         uint64             `json:"revisionNumber"`
	Version                string             `json:"version"`

	// RHP3 specific fields
	EphemeralAccountExpiry     time.Duration  `json:"ephemeralAccountExpiry"`
	MaxEphemeralAccountBalance types.Currency `json:"maxEphemeralAccountBalance"`
	SiaMuxPort                 string         `json:"siaMuxPort"`

	// nonstandard fields
	Make  string `json:"make"`
	Model string `json:"model"`
}

HostSettings are the settings reported by a host.

type ScannedHost

type ScannedHost struct {
	HostSettings
	PublicKey HostPublicKey
	Latency   time.Duration
}

ScannedHost groups a host's settings with its public key and other scan- related metrics.

func Scan

func Scan(ctx context.Context, addr modules.NetAddress, pubkey HostPublicKey) (host ScannedHost, err error)

Scan dials the host with the given NetAddress and public key and requests its settings.

Jump to

Keyboard shortcuts

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