types.gno
1.70 Kb · 69 lines
1package idlewatt
2
3import "time"
4
5// Node kinds.
6const (
7 KindHomeGPU = "home-gpu"
8 KindVehicle = "vehicle"
9 KindCPU = "cpu"
10)
11
12// Power sources.
13const (
14 PowerGrid = "grid"
15 PowerSolar = "solar"
16 PowerPowershare = "powershare-backup"
17)
18
19// Availability modes.
20const (
21 ModeAvailable = "available" // parked & plugged in, ready for work
22 ModeDriving = "driving" // vehicle in use, not renting compute
23 ModePaused = "paused" // operator paused the node
24)
25
26// Node is one idle-compute node registered by an operator.
27// All figures are self-reported by the operator; nothing here is verified
28// by Akash, Tesla or any hardware attestation (yet).
29type Node struct {
30 ID int
31 Operator address
32 Name string
33 Kind string
34 Hardware string
35 Region string
36 Power string
37 RateCents int64 // asking price, USD cents per hour
38 Mode string
39
40 RegisteredAt time.Time
41 LastHeartbeat time.Time // zero if never
42 SessionStart time.Time // start of the current unbroken heartbeat run
43 HeartbeatCount int
44 LastNote string
45
46 JobCount int
47 JobMinutes int64
48 EarnedCents int64 // operator share of simulated job earnings
49 BonusCents int64 // share of the small-node fairness pool
50}
51
52// TotalCents is what the leaderboard ranks on.
53func (n *Node) TotalCents() int64 {
54 return n.EarnedCents + n.BonusCents
55}
56
57// Job is one simulated (self-reported) lease / job completion.
58type Job struct {
59 ID int
60 NodeID int
61 NodeName string // snapshot, survives node removal
62 Workload string
63 Minutes int
64 RateCents int64
65 GrossCents int64 // rate x duration
66 PoolCents int64 // part sent to the fairness pool
67 OperatorCents int64
68 CompletedAt time.Time
69}