Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ld
go-ld-prime
Commits
f538ddd4
Unverified
Commit
f538ddd4
authored
Jul 29, 2019
by
Eric Myhre
Committed by
GitHub
Jul 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23 from ipld/bugs/cbor-link-traversal
fix(encoding): match go-ipld-cbor cid encoding
parents
27a6b503
015389d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
encoding/dagcbor/marshal.go
encoding/dagcbor/marshal.go
+1
-1
encoding/dagcbor/unmarshal.go
encoding/dagcbor/unmarshal.go
+9
-1
No files found.
encoding/dagcbor/marshal.go
View file @
f538ddd4
...
...
@@ -127,7 +127,7 @@ func Marshal(n ipld.Node, sink shared.TokenSink) error {
switch
lnk
:=
v
.
(
type
)
{
case
cidlink
.
Link
:
tk
.
Type
=
tok
.
TBytes
tk
.
Bytes
=
lnk
.
Bytes
()
tk
.
Bytes
=
append
([]
byte
{
0
},
lnk
.
Bytes
()
...
)
tk
.
Tagged
=
true
tk
.
Tag
=
linkTag
_
,
err
=
sink
.
Step
(
&
tk
)
...
...
encoding/dagcbor/unmarshal.go
View file @
f538ddd4
package
dagcbor
import
(
"errors"
"fmt"
"math"
...
...
@@ -12,6 +13,10 @@ import (
cidlink
"github.com/ipld/go-ipld-prime/linking/cid"
)
var
(
ErrInvalidMultibase
=
errors
.
New
(
"invalid multibase on IPLD link"
)
)
// This should be identical to the general feature in the parent package,
// except for the `case tok.TBytes` block,
// which has dag-cbor's special sauce for detecting schemafree links.
...
...
@@ -126,7 +131,10 @@ func unmarshal(nb ipld.NodeBuilder, tokSrc shared.TokenSource, tk *tok.Token) (i
}
switch
tk
.
Tag
{
case
linkTag
:
elCid
,
err
:=
cid
.
Cast
(
tk
.
Bytes
)
if
tk
.
Bytes
[
0
]
!=
0
{
return
nil
,
ErrInvalidMultibase
}
elCid
,
err
:=
cid
.
Cast
(
tk
.
Bytes
[
1
:
])
if
err
!=
nil
{
return
nil
,
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment