hostdb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BenchmarkHistory

type BenchmarkHistory struct {
	HostBenchmark
	PublicKey types.PublicKey `json:"publicKey"`
	Network   string          `json:"network"`
	Node      string          `json:"node"`
}

BenchmarkHistory combines the benchmark history with the host's public key.

type HostBenchmark

type HostBenchmark struct {
	ID            int64         `json:"-"`
	Timestamp     time.Time     `json:"timestamp"`
	Success       bool          `json:"success"`
	Error         string        `json:"error"`
	UploadSpeed   float64       `json:"uploadSpeed"`
	DownloadSpeed float64       `json:"downloadSpeed"`
	TTFB          time.Duration `json:"ttfb"`
}

A HostBenchmark contains the information measured during a host benchmark.

type HostDB

type HostDB struct {
	// contains filtered or unexported fields
}

The HostDB is a database of hosts.

func NewHostDB

func NewHostDB(db *sql.DB, dir string, cm *chain.Manager, cmZen *chain.Manager, syncer *syncer.Syncer, syncerZen *syncer.Syncer, w *walletutil.Wallet) (*HostDB, <-chan error)

NewHostDB returns a new HostDB.

func (*HostDB) Close

func (hdb *HostDB) Close()

Close shuts down HostDB.

func (*HostDB) FinalizeUpdates

func (hdb *HostDB) FinalizeUpdates(id UpdateID) error

FinalizeUpdates updates the timestamps after the client confirms the data receipt.

func (*HostDB) IncrementFailedInteractions

func (hdb *HostDB) IncrementFailedInteractions(host *HostDBEntry) error

IncrementFailedInteractions increments the number of failed interactions with a given host.

func (*HostDB) IncrementSuccessfulInteractions

func (hdb *HostDB) IncrementSuccessfulInteractions(host *HostDBEntry) error

IncrementSuccessfulInteractions increments the number of successful interactions with a given host.

func (*HostDB) RecentUpdates

func (hdb *HostDB) RecentUpdates() (HostUpdates, error)

RecentUpdates returns a list of the most recent updates since the last retrieval.

type HostDBEntry

type HostDBEntry struct {
	ID            int                        `json:"id"`
	Network       string                     `json:"network"`
	PublicKey     types.PublicKey            `json:"publicKey"`
	FirstSeen     time.Time                  `json:"firstSeen"`
	KnownSince    uint64                     `json:"knownSince"`
	NetAddress    string                     `json:"netaddress"`
	Blocked       bool                       `json:"blocked"`
	Uptime        time.Duration              `json:"uptime"`
	Downtime      time.Duration              `json:"downtime"`
	ScanHistory   []HostScan                 `json:"scanHistory"`
	LastBenchmark HostBenchmark              `json:"lastBenchmark"`
	Interactions  HostInteractions           `json:"interactions"`
	LastSeen      time.Time                  `json:"lastSeen"`
	IPNets        []string                   `json:"ipNets"`
	ActiveHosts   int                        `json:"activeHosts"`
	LastIPChange  time.Time                  `json:"lastIPChange"`
	Revision      types.FileContractRevision `json:"-"`
	Settings      rhpv2.HostSettings         `json:"settings"`
	PriceTable    rhpv3.HostPriceTable       `json:"priceTable"`
	external.IPInfo
}

A HostDBEntry represents one host entry in the HostDB. It aggregates the host's external settings and metrics with its public key.

type HostInteractions

type HostInteractions struct {
	HistoricSuccesses float64 `json:"historicSuccessfulInteractions"`
	HistoricFailures  float64 `json:"historicFailedInteractions"`
	RecentSuccesses   float64 `json:"recentSuccessfulInteractions"`
	RecentFailures    float64 `json:"recentFailedInteractions"`
	LastUpdate        uint64  `json:"-"`
}

HostInteractions combines historic and recent interactions.

type HostScan

type HostScan struct {
	ID         int64                `json:"-"`
	Timestamp  time.Time            `json:"timestamp"`
	Success    bool                 `json:"success"`
	Latency    time.Duration        `json:"latency"`
	Error      string               `json:"error"`
	Settings   rhpv2.HostSettings   `json:"settings"`
	PriceTable rhpv3.HostPriceTable `json:"priceTable"`
}

A HostScan contains all information measured during a host scan.

type HostUpdates

type HostUpdates struct {
	ID         UpdateID           `json:"id"`
	Hosts      []HostDBEntry      `json:"hosts"`
	Scans      []ScanHistory      `json:"scans"`
	Benchmarks []BenchmarkHistory `json:"benchmarks"`
}

HostUpdates represents a batch of updates sent to the client.

type ScanHistory

type ScanHistory struct {
	HostScan
	PublicKey types.PublicKey `json:"publicKey"`
	Network   string          `json:"network"`
	Node      string          `json:"node"`
}

ScanHistory combines the scan history with the host's public key.

type UpdateID

type UpdateID = [8]byte

UpdateID is the ID of a HostUpdate.

Jump to

Keyboard shortcuts

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