Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/f3/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func main() {
&runCmd,
&manifestCmd,
&observerCmd,
&toolsCmd,
},
}

Expand Down
39 changes: 39 additions & 0 deletions cmd/f3/tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"encoding/json"
"fmt"
"os"

"github.com/filecoin-project/go-f3/certs"
"github.com/filecoin-project/go-f3/gpbft"
"github.com/urfave/cli/v2"
)

var toolsCmd = cli.Command{
Name: "tools",
Usage: "various tools for f3",
Subcommands: []*cli.Command{
&ptCidCmd,
},
}

var ptCidCmd = cli.Command{
Name: "ptCid",
Usage: "compute the CID of a json power table",
Action: func(c *cli.Context) error {
var entries gpbft.PowerEntries
err := json.NewDecoder(os.Stdin).Decode(&entries)
if err != nil {
return fmt.Errorf("error while decoding: %w", err)
}

cid, err := certs.MakePowerTableCID(entries)
if err != nil {
return fmt.Errorf("error while computing CID: %w", err)
}

fmt.Printf("%s\n", cid)
return nil
},
}
Loading