forked from NebulousLabs/Sia
/
host.go
66 lines (52 loc) · 1.75 KB
/
host.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package modules
import (
"github.com/NebulousLabs/Sia/types"
)
const (
AcceptResponse = "accept"
HostDir = "host"
)
// RPC identifiers
var (
// Each identifier has a version number at the end, which will be
// incremented whenever the protocol changes.
RPCSettings = types.Specifier{'S', 'e', 't', 't', 'i', 'n', 'g', 's', 0}
RPCUpload = types.Specifier{'U', 'p', 'l', 'o', 'a', 'd', 0}
RPCRevise = types.Specifier{'R', 'e', 'v', 'i', 's', 'e', 0}
RPCDownload = types.Specifier{'D', 'o', 'w', 'n', 'l', 'o', 'a', 'd', 0}
)
// A DownloadRequest is used to retrieve a particular segment of a file from a
// host.
type DownloadRequest struct {
Offset uint64
Length uint64
}
// HostInfo contains HostSettings and details pertinent to the host's understanding
// of their offered services
type HostInfo struct {
HostSettings
StorageRemaining int64
NumContracts int
Profit types.Currency
PotentialProfit types.Currency
Competition types.Currency
}
type Host interface {
// Address returns the host's network address
Address() NetAddress
// Announce announces the host on the blockchain, returning an error if the
// host cannot reach itself or if the external ip address is unknown.
Announce() error
// ForceAnnounce announces the specified address on the blockchain,
// regardless of connectivity.
ForceAnnounce(NetAddress) error
// SetConfig sets the hosting parameters of the host.
SetSettings(HostSettings)
// Settings returns the host's settings.
Settings() HostSettings
// Info returns info about the host, including its hosting parameters, the
// amount of storage remaining, and the number of active contracts.
Info() HostInfo
// Close saves the state of the host and stops its listener process.
Close() error
}