Commit a0ab751a authored by Kevin Atkinson's avatar Kevin Atkinson

gx update and fix code to use new Cid type

parent 0e1a8db3
...@@ -22,7 +22,7 @@ func main() { ...@@ -22,7 +22,7 @@ func main() {
usage() usage()
} }
newBase := mb.Encoding(-1) 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:] args := os.Args[1:]
outer: outer:
for { for {
...@@ -117,13 +117,13 @@ func errorMsg(fmtStr string, a ...interface{}) { ...@@ -117,13 +117,13 @@ func errorMsg(fmtStr string, a ...interface{}) {
exitCode = 1 exitCode = 1
} }
func toCidV0(cid *c.Cid) (*c.Cid, error) { func toCidV0(cid c.Cid) (c.Cid, error) {
if cid.Type() != c.DagProtobuf { if cid.Type() != c.DagProtobuf {
return nil, fmt.Errorf("can't convert non-protobuf nodes to cidv0") return c.Cid{}, fmt.Errorf("can't convert non-protobuf nodes to cidv0")
} }
return c.NewCidV0(cid.Hash()), nil 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 return c.NewCidV1(cid.Type(), cid.Hash()), nil
} }
...@@ -35,7 +35,7 @@ used. For Cid version 1 the multibase prefix is included. ...@@ -35,7 +35,7 @@ used. For Cid version 1 the multibase prefix is included.
// Format formats a cid according to the format specificer as // Format formats a cid according to the format specificer as
// documented in the FormatRef constant // documented in the FormatRef constant
func Format(fmtStr string, base mb.Encoding, cid *c.Cid) (string, error) { func Format(fmtStr string, base mb.Encoding, cid c.Cid) (string, error) {
p := cid.Prefix() p := cid.Prefix()
var out bytes.Buffer var out bytes.Buffer
var err error var err error
......
...@@ -18,7 +18,7 @@ func (p InlineBuilder) WithCodec(c uint64) cid.Builder { ...@@ -18,7 +18,7 @@ func (p InlineBuilder) WithCodec(c uint64) cid.Builder {
} }
// Sum implements the cid.Builder interface // Sum implements the cid.Builder interface
func (p InlineBuilder) Sum(data []byte) (*cid.Cid, error) { func (p InlineBuilder) Sum(data []byte) (cid.Cid, error) {
if len(data) > p.Limit { if len(data) > p.Limit {
return p.Builder.Sum(data) return p.Builder.Sum(data)
} }
......
...@@ -13,15 +13,15 @@ ...@@ -13,15 +13,15 @@
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmSbvata2WqNkqGtZNg8MR3SKwnB8iQ7vTPJgWqB8bC5kR", "hash": "QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd",
"name": "go-multibase", "name": "go-multibase",
"version": "0.2.7" "version": "0.3.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb", "hash": "QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7",
"name": "go-cid", "name": "go-cid",
"version": "0.8.0" "version": "0.9.0"
} }
], ],
"gxVersion": "0.12.1", "gxVersion": "0.12.1",
......
...@@ -14,21 +14,21 @@ func NewSet() *Set { return c.NewSet() } ...@@ -14,21 +14,21 @@ func NewSet() *Set { return c.NewSet() }
// for the Visit function // for the Visit function
type StreamingSet struct { type StreamingSet struct {
Set *Set Set *Set
New chan *c.Cid New chan c.Cid
} }
// NewStreamingSet initializes and returns new Set. // NewStreamingSet initializes and returns new Set.
func NewStreamingSet() *StreamingSet { func NewStreamingSet() *StreamingSet {
return &StreamingSet{ return &StreamingSet{
Set: c.NewSet(), Set: c.NewSet(),
New: make(chan *c.Cid), New: make(chan c.Cid),
} }
} }
// Visitor creates new visitor which adds a Cids to the set and emits them to // Visitor creates new visitor which adds a Cids to the set and emits them to
// the set.New channel // the set.New channel
func (s *StreamingSet) Visitor(ctx context.Context) func(c *c.Cid) bool { func (s *StreamingSet) Visitor(ctx context.Context) func(c c.Cid) bool {
return func(c *c.Cid) bool { return func(c c.Cid) bool {
if s.Set.Visit(c) { if s.Set.Visit(c) {
select { select {
case s.New <- c: case s.New <- c:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment