From c0204cdd83e5f93c27001eb5c5335783d384dc9c Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Wed, 15 Apr 2020 13:50:46 -0400 Subject: [PATCH] Add a shed command to turn raw commPs into CIDs --- cmd/lotus-shed/commp.go | 17 +++++++++++++++++ cmd/lotus-shed/main.go | 1 + 2 files changed, 18 insertions(+) create mode 100644 cmd/lotus-shed/commp.go diff --git a/cmd/lotus-shed/commp.go b/cmd/lotus-shed/commp.go new file mode 100644 index 000000000..c9808c19a --- /dev/null +++ b/cmd/lotus-shed/commp.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + commcid "github.com/filecoin-project/go-fil-commcid" + "gopkg.in/urfave/cli.v2" +) + +var commpToCidCmd = &cli.Command{ + Name: "commp-to-cid", + Description: "Convert a raw commP to a piece-Cid", + Action: func(cctx *cli.Context) error { + cp := []byte(cctx.Args().Get(0)) + fmt.Println(commcid.PieceCommitmentV1ToCID(cp)) + return nil + }, +} diff --git a/cmd/lotus-shed/main.go b/cmd/lotus-shed/main.go index d31151184..7a950e14a 100644 --- a/cmd/lotus-shed/main.go +++ b/cmd/lotus-shed/main.go @@ -23,6 +23,7 @@ func main() { bigIntParseCmd, staterootStatsCmd, importCarCmd, + commpToCidCmd, } app := &cli.App{