Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Make Cid an interface and change default representation to a String #64

Closed
wants to merge 5 commits into from
Closed
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
10 changes: 5 additions & 5 deletions cid-fmt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func main() {
usage()
}
newBase := mb.Encoding(-1)
var verConv func(cid *c.Cid) (*c.Cid, error)
var verConv func(cid c.Cid) (c.Cid, error)
args := os.Args[1:]
outer:
for {
Expand Down Expand Up @@ -132,7 +132,7 @@ func errorMsg(fmtStr string, a ...interface{}) {
exitCode = 1
}

func decode(v string) (mb.Encoding, *c.Cid, error) {
func decode(v string) (mb.Encoding, c.Cid, error) {
if len(v) < 2 {
return 0, nil, c.ErrCidTooShort
}
Expand All @@ -158,7 +158,7 @@ func decode(v string) (mb.Encoding, *c.Cid, error) {

const ERR_STR = "!ERROR!"

func fmtCid(fmtStr string, base mb.Encoding, cid *c.Cid) (string, error) {
func fmtCid(fmtStr string, base mb.Encoding, cid c.Cid) (string, error) {
p := cid.Prefix()
out := new(bytes.Buffer)
var err error
Expand Down Expand Up @@ -265,13 +265,13 @@ func encode(base mb.Encoding, data []byte, strip bool) string {
return str
}

func toCidV0(cid *c.Cid) (*c.Cid, error) {
func toCidV0(cid c.Cid) (c.Cid, error) {
if cid.Type() != c.DagProtobuf {
return nil, fmt.Errorf("can't convert non-protobuf nodes to cidv0")
}
return c.NewCidV0(cid.Hash()), nil
}

func toCidV1(cid *c.Cid) (*c.Cid, error) {
func toCidV1(cid c.Cid) (c.Cid, error) {
return c.NewCidV1(cid.Type(), cid.Hash()), nil
}
Loading