File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ func main() {
2525 & runCmd ,
2626 & manifestCmd ,
2727 & observerCmd ,
28+ & toolsCmd ,
2829 },
2930 }
3031
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "encoding/json"
5+ "fmt"
6+ "os"
7+
8+ "github.com/filecoin-project/go-f3/certs"
9+ "github.com/filecoin-project/go-f3/gpbft"
10+ "github.com/urfave/cli/v2"
11+ )
12+
13+ var toolsCmd = cli.Command {
14+ Name : "tools" ,
15+ Usage : "various tools for f3" ,
16+ Subcommands : []* cli.Command {
17+ & ptCidCmd ,
18+ },
19+ }
20+
21+ var ptCidCmd = cli.Command {
22+ Name : "ptCid" ,
23+ Usage : "compute the CID of a json power table" ,
24+ Action : func (c * cli.Context ) error {
25+ var entries gpbft.PowerEntries
26+ err := json .NewDecoder (os .Stdin ).Decode (& entries )
27+ if err != nil {
28+ return fmt .Errorf ("error while decoding: %w" , err )
29+ }
30+
31+ cid , err := certs .MakePowerTableCID (entries )
32+ if err != nil {
33+ return fmt .Errorf ("error while computing CID: %w" , err )
34+ }
35+
36+ fmt .Printf ("%s\n " , cid )
37+ return nil
38+ },
39+ }
You can’t perform that action at this time.
0 commit comments