-
Notifications
You must be signed in to change notification settings - Fork 93
/
miners.go
104 lines (95 loc) · 1.84 KB
/
miners.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package stub
import (
"context"
"time"
"github.com/textileio/powergate/index/miner"
)
// Miners provides an API for viewing miner data.
type Miners struct {
}
// Get returns the current index of available asks.
func (a *Miners) Get(ctx context.Context) (*miner.IndexSnapshot, error) {
time.Sleep(time.Second * 3)
info := map[string]miner.Meta{
"miner1": {
LastUpdated: time.Now(),
UserAgent: "miner1agent",
Location: miner.Location{
Country: "US",
Longitude: 111.1,
Latitude: 45.34,
},
Online: true,
},
"miner2": {
LastUpdated: time.Now(),
UserAgent: "miner2agent",
Location: miner.Location{
Country: "US",
Longitude: 111.1,
Latitude: 45.34,
},
Online: true,
},
"miner3": {
LastUpdated: time.Now(),
UserAgent: "miner3agent",
Location: miner.Location{
Country: "US",
Longitude: 111.1,
Latitude: 45.34,
},
Online: true,
},
"miner4": {
LastUpdated: time.Now(),
UserAgent: "miner4agent",
Location: miner.Location{
Country: "US",
Longitude: 111.1,
Latitude: 45.34,
},
Online: true,
},
}
metaIndex := miner.MetaIndex{
Online: 4,
Offline: 11,
Info: info,
}
miners := map[string]miner.OnChainData{
"miner1": {
Power: 88,
RelativePower: 0.5,
SectorSize: 512,
ActiveDeals: 10,
},
"miner2": {
Power: 46,
RelativePower: 0.34,
SectorSize: 512,
ActiveDeals: 12,
},
"miner3": {
Power: 3,
RelativePower: 0.84,
SectorSize: 1024,
ActiveDeals: 1,
},
"miner4": {
Power: 234,
RelativePower: 0.14,
SectorSize: 512,
ActiveDeals: 3,
},
}
chainIndex := miner.ChainIndex{
LastUpdated: 2134567,
Miners: miners,
}
index := &miner.IndexSnapshot{
Meta: metaIndex,
OnChain: chainIndex,
}
return index, nil
}