Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

gx update and fix code to use new Cid type #15

Merged
merged 2 commits into from
Sep 12, 2018
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
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.16: QmWAfTyD6KEBm7bzqNRBPvqKrZCDtn5PGbs9V1DKfnVK59
1.1.0: QmPXzQ9LAFGZjcifFANCQFQiYt5SXgJziGoxUfJULVpHyA
6 changes: 3 additions & 3 deletions io/pbdagreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type PBDagReader struct {
promises []*ipld.NodePromise

// the cid of each child of the current node
links []*cid.Cid
links []cid.Cid

// the index of the child link currently being read from
linkPosition int
Expand Down Expand Up @@ -151,9 +151,9 @@ func (dr *PBDagReader) loadBufNode(node ipld.Node) error {
}
}

func getLinkCids(n ipld.Node) []*cid.Cid {
func getLinkCids(n ipld.Node) []cid.Cid {
links := n.Links()
out := make([]*cid.Cid, 0, len(links))
out := make([]cid.Cid, 0, len(links))
for _, l := range links {
out = append(out, l.Cid)
}
Expand Down
26 changes: 13 additions & 13 deletions mod/dagmodifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,33 +233,33 @@ func (dm *DagModifier) Sync() error {

// modifyDag writes the data in 'dm.wrBuf' over the data in 'node' starting at 'offset'
// returns the new key of the passed in node.
func (dm *DagModifier) modifyDag(n ipld.Node, offset uint64) (*cid.Cid, error) {
func (dm *DagModifier) modifyDag(n ipld.Node, offset uint64) (cid.Cid, error) {
// If we've reached a leaf node.
if len(n.Links()) == 0 {
switch nd0 := n.(type) {
case *mdag.ProtoNode:
f, err := ft.FromBytes(nd0.Data())
if err != nil {
return nil, err
return cid.Cid{}, err
}

_, err = dm.wrBuf.Read(f.Data[offset:])
if err != nil && err != io.EOF {
return nil, err
return cid.Cid{}, err
}

// Update newly written node..
b, err := proto.Marshal(f)
if err != nil {
return nil, err
return cid.Cid{}, err
}

nd := new(mdag.ProtoNode)
nd.SetData(b)
nd.SetCidBuilder(nd0.CidBuilder())
err = dm.dagserv.Add(dm.ctx, nd)
if err != nil {
return nil, err
return cid.Cid{}, err
}

return nd.Cid(), nil
Expand All @@ -273,7 +273,7 @@ func (dm *DagModifier) modifyDag(n ipld.Node, offset uint64) (*cid.Cid, error) {
// copy in new data
n, err := dm.wrBuf.Read(bytes[offset:])
if err != nil && err != io.EOF {
return nil, err
return cid.Cid{}, err
}

// copy remaining data
Expand All @@ -284,11 +284,11 @@ func (dm *DagModifier) modifyDag(n ipld.Node, offset uint64) (*cid.Cid, error) {

nd, err := mdag.NewRawNodeWPrefix(bytes, nd0.Cid().Prefix())
if err != nil {
return nil, err
return cid.Cid{}, err
}
err = dm.dagserv.Add(dm.ctx, nd)
if err != nil {
return nil, err
return cid.Cid{}, err
}

return nd.Cid(), nil
Expand All @@ -297,12 +297,12 @@ func (dm *DagModifier) modifyDag(n ipld.Node, offset uint64) (*cid.Cid, error) {

node, ok := n.(*mdag.ProtoNode)
if !ok {
return nil, ErrNotUnixfs
return cid.Cid{}, ErrNotUnixfs
}

f, err := ft.FromBytes(node.Data())
if err != nil {
return nil, err
return cid.Cid{}, err
}

var cur uint64
Expand All @@ -311,20 +311,20 @@ func (dm *DagModifier) modifyDag(n ipld.Node, offset uint64) (*cid.Cid, error) {
if cur+bs > offset {
child, err := node.Links()[i].GetNode(dm.ctx, dm.dagserv)
if err != nil {
return nil, err
return cid.Cid{}, err
}

k, err := dm.modifyDag(child, offset-cur)
if err != nil {
return nil, err
return cid.Cid{}, err
}

node.Links()[i].Cid = k

// Recache serialized node
_, err = node.EncodeProtobuf(true)
if err != nil {
return nil, err
return cid.Cid{}, err
}

if dm.wrBuf.Len() == 0 {
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
},
{
"author": "why",
"hash": "QmNr4E8z9bGTztvHJktp7uQaMdx9p3r9Asrq6eYk7iCh4a",
"hash": "QmURqt1jB9Yu3X4Tr9WQJf36QGN7vi8mGTzjnX2ij1CJwC",
"name": "go-merkledag",
"version": "1.0.14"
"version": "1.1.0"
},
{
"author": "hector",
"hash": "QmXD4grfThQ4LwVoEEfe4dgR7ukmbV9TppM5Q4SPowp7hU",
"hash": "QmPG32VXR5jmpo9q8R9FNdR4Ae97Ky9CiZE6SctJLUB79H",
"name": "go-ipfs-posinfo",
"version": "0.0.6"
"version": "0.1.0"
},
{
"author": "Stebalien",
Expand All @@ -50,15 +50,15 @@
},
{
"author": "hsanjuan",
"hash": "QmXzBbJo2sLf3uwjNTeoWYiJV7CjAhkiA4twtLvwJSSNdK",
"hash": "QmdSeG9s4EQ9TGruJJS9Us38TQDZtMmFGwzTYUDVqNTURm",
"name": "go-ipfs-chunker",
"version": "0.0.11"
"version": "0.1.0"
},
{
"author": "whyrusleeping",
"hash": "QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb",
"hash": "QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7",
"name": "go-cid",
"version": "0.8.0"
"version": "0.9.0"
},
{
"author": "whyrusleeping",
Expand All @@ -68,16 +68,16 @@
},
{
"author": "whyrusleeping",
"hash": "QmX5CsuHyVZeTLxgRSYkgLSDQKb9UjE8xnhQzCEJWWWFsC",
"hash": "QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL",
"name": "go-ipld-format",
"version": "0.5.8"
"version": "0.6.0"
}
],
"gxVersion": "0.12.1",
"language": "go",
"license": "",
"name": "go-unixfs",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "1.0.16"
"version": "1.1.0"
}