forked from irinazheltisheva/powergate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaults.go
More file actions
33 lines (26 loc) · 778 Bytes
/
faults.go
File metadata and controls
33 lines (26 loc) · 778 Bytes
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
package client
import (
"context"
"github.com/textileio/powergate/index/faults"
"github.com/textileio/powergate/index/faults/rpc"
)
// Faults provides an API for viewing faults data.
type Faults struct {
client rpc.RPCServiceClient
}
// Get returns the current index of miner faults data.
func (s *Faults) Get(ctx context.Context) (*faults.IndexSnapshot, error) {
reply, err := s.client.Get(ctx, &rpc.GetRequest{})
if err != nil {
return nil, err
}
miners := make(map[string]faults.Faults, len(reply.GetIndex().GetMiners()))
for key, val := range reply.GetIndex().GetMiners() {
miners[key] = faults.Faults{Epochs: val.GetEpochs()}
}
index := &faults.IndexSnapshot{
TipSetKey: reply.GetIndex().GetTipsetkey(),
Miners: miners,
}
return index, nil
}