Commit eefce3cb authored by tavit ohanian's avatar tavit ohanian

refactor after forking multiformats

parent d66d955d
Pipeline #1106 passed with stages
in 26 seconds
stages:
- build
- test
variables:
BUILD_DIR: "/tmp/$CI_CONCURRENT_PROJECT_ID"
before_script:
- mkdir -p $BUILD_DIR/src
- cd $BUILD_DIR/src
- if [ -d $CI_PROJECT_DIR ]
- then
- echo "soft link $CI_PROJECT_DIR exists"
- else
- echo "creating soft link $CI_PROJECT_DIR"
- ln -s $CI_PROJECT_DIR
- fi
- cd $CI_PROJECT_DIR
build:
stage: build
tags:
- testing
script:
- echo $CI_JOB_STAGE
- go build
test:
stage: test
tags:
- testing
script:
- echo $CI_JOB_STAGE
- go test -cover
coverage: '/coverage: \d+.\d+% of statements/'
# go-dagpb # go-dagpb
**An implementation of the IPLD [DAG-PB](https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-pb.md) spec for [go-ipld-prime](https://github.com/ipld/go-ipld-prime/)** **An implementation of the IPLD [DAG-PB](https://gitlab.dms3.io/ld/specs/blob/master/block-layer/codecs/dag-pb.md) spec for [go-ld-prime](https://gitlab.dms3.io/ld/go-ld-prime/)**
Use `Decode(ipld.NodeAssembler, io.Reader)` and `Encode(ipld.Node, io.Writer)` directly, or import this package to have this codec registered into the go-ipld-prime CID link loader. Use `Decode(ld.NodeAssembler, io.Reader)` and `Encode(ld.Node, io.Writer)` directly, or import this package to have this codec registered into the go-ld-prime CID link loader.
Nodes encoded with this codec _must_ conform to the DAG-PB spec. Specifically, they should have the non-optional fields shown in the DAG-PB schema: Nodes encoded with this codec _must_ conform to the DAG-PB spec. Specifically, they should have the non-optional fields shown in the DAG-PB schema:
```ipldsch ```ldsch
type PBNode struct { type PBNode struct {
Links [PBLink] Links [PBLink]
Data optional Bytes Data optional Bytes
...@@ -19,7 +19,7 @@ type PBLink struct { ...@@ -19,7 +19,7 @@ type PBLink struct {
} }
``` ```
Use `dagpb.Type.PBNode` and friends directly for strictness guarantees. Basic `ipld.Node`s will need to have the appropraite fields (and no others) to successfully encode using this codec. Use `dagpb.Type.PBNode` and friends directly for strictness guarantees. Basic `ld.Node`s will need to have the appropraite fields (and no others) to successfully encode using this codec.
## License & Copyright ## License & Copyright
......
...@@ -5,11 +5,11 @@ import ( ...@@ -5,11 +5,11 @@ import (
"encoding/hex" "encoding/hex"
"testing" "testing"
"github.com/ipfs/go-cid" "gitlab.dms3.io/dms3/go-cid"
"github.com/ipld/go-ipld-prime" "gitlab.dms3.io/ld/go-ld-prime"
"github.com/ipld/go-ipld-prime/fluent" "gitlab.dms3.io/ld/go-ld-prime/fluent"
cidlink "github.com/ipld/go-ipld-prime/linking/cid" cidlink "gitlab.dms3.io/ld/go-ld-prime/linking/cid"
basicnode "github.com/ipld/go-ipld-prime/node/basic" basicnode "gitlab.dms3.io/ld/go-ld-prime/node/basic"
) )
type pbNode struct { type pbNode struct {
...@@ -25,7 +25,7 @@ func mkcid(t *testing.T, cidStr string) cid.Cid { ...@@ -25,7 +25,7 @@ func mkcid(t *testing.T, cidStr string) cid.Cid {
return c return c
} }
func validate(t *testing.T, actual ipld.Node, expected pbNode) { func validate(t *testing.T, actual ld.Node, expected pbNode) {
mi := actual.MapIterator() mi := actual.MapIterator()
_, isTyped := actual.(*_PBNode) _, isTyped := actual.(*_PBNode)
...@@ -41,7 +41,7 @@ func validate(t *testing.T, actual ipld.Node, expected pbNode) { ...@@ -41,7 +41,7 @@ func validate(t *testing.T, actual ipld.Node, expected pbNode) {
t.Fatal(err) t.Fatal(err)
} }
if keyStr == "Links" { if keyStr == "Links" {
if val.Kind() != ipld.Kind_List { if val.Kind() != ld.Kind_List {
t.Fatal("Links is not a list") t.Fatal("Links is not a list")
} }
if val.IsAbsent() { if val.IsAbsent() {
...@@ -59,7 +59,7 @@ func validate(t *testing.T, actual ipld.Node, expected pbNode) { ...@@ -59,7 +59,7 @@ func validate(t *testing.T, actual ipld.Node, expected pbNode) {
if !val.IsAbsent() { if !val.IsAbsent() {
t.Fatalf("Empty Data is not marked as absent") t.Fatalf("Empty Data is not marked as absent")
} }
if val.Kind() != ipld.Kind_Null { if val.Kind() != ld.Kind_Null {
t.Fatal("Empty Data is not null") t.Fatal("Empty Data is not null")
} }
if val.IsNull() { if val.IsNull() {
...@@ -94,7 +94,7 @@ func validate(t *testing.T, actual ipld.Node, expected pbNode) { ...@@ -94,7 +94,7 @@ func validate(t *testing.T, actual ipld.Node, expected pbNode) {
func runTest(t *testing.T, bytsHex string, expected pbNode) { func runTest(t *testing.T, bytsHex string, expected pbNode) {
byts, _ := hex.DecodeString(bytsHex) byts, _ := hex.DecodeString(bytsHex)
roundTrip := func(t *testing.T, node ipld.Node) { roundTrip := func(t *testing.T, node ld.Node) {
var buf bytes.Buffer var buf bytes.Buffer
if err := Encode(node, &buf); err != nil { if err := Encode(node, &buf); err != nil {
t.Fatal(err) t.Fatal(err)
......
package dagpb package dagpb
// mirrored in JavaScript @ https://github.com/ipld/js-dag-pb/blob/master/test/test-compat.js // mirrored in JavaScript @ https://gitlab.dms3.io/ld/js-dag-pb/blob/master/test/test-compat.js
import ( import (
"bytes" "bytes"
...@@ -9,11 +9,11 @@ import ( ...@@ -9,11 +9,11 @@ import (
"strings" "strings"
"testing" "testing"
cid "github.com/ipfs/go-cid" cid "gitlab.dms3.io/dms3/go-cid"
"github.com/ipld/go-ipld-prime" "gitlab.dms3.io/ld/go-ld-prime"
"github.com/ipld/go-ipld-prime/fluent" "gitlab.dms3.io/ld/go-ld-prime/fluent"
cidlink "github.com/ipld/go-ipld-prime/linking/cid" cidlink "gitlab.dms3.io/ld/go-ld-prime/linking/cid"
basicnode "github.com/ipld/go-ipld-prime/node/basic" basicnode "gitlab.dms3.io/ld/go-ld-prime/node/basic"
) )
var dataZero []byte = make([]byte, 0) var dataZero []byte = make([]byte, 0)
...@@ -257,7 +257,7 @@ func verifyRoundTrip(t *testing.T, tc testCase) { ...@@ -257,7 +257,7 @@ func verifyRoundTrip(t *testing.T, tc testCase) {
} }
} }
func buildNode(n pbNode) ipld.Node { func buildNode(n pbNode) ld.Node {
return fluent.MustBuildMap(basicnode.Prototype__Map{}, 2, func(fma fluent.MapAssembler) { return fluent.MustBuildMap(basicnode.Prototype__Map{}, 2, func(fma fluent.MapAssembler) {
if n.data != nil { if n.data != nil {
fma.AssembleEntry("Data").AssignBytes(n.data) fma.AssembleEntry("Data").AssignBytes(n.data)
...@@ -282,7 +282,7 @@ func buildNode(n pbNode) ipld.Node { ...@@ -282,7 +282,7 @@ func buildNode(n pbNode) ipld.Node {
}) })
} }
func nodeToString(t *testing.T, node ipld.Node) (string, error) { func nodeToString(t *testing.T, node ld.Node) (string, error) {
var buf bytes.Buffer var buf bytes.Buffer
err := Marshal(node, &buf) err := Marshal(node, &buf)
if err != nil { if err != nil {
...@@ -293,7 +293,7 @@ func nodeToString(t *testing.T, node ipld.Node) (string, error) { ...@@ -293,7 +293,7 @@ func nodeToString(t *testing.T, node ipld.Node) (string, error) {
return h, nil return h, nil
} }
func bytesToFormString(t *testing.T, bytesHex string, nb ipld.NodeBuilder) (string, error) { func bytesToFormString(t *testing.T, bytesHex string, nb ld.NodeBuilder) (string, error) {
byts, err := hex.DecodeString(bytesHex) byts, err := hex.DecodeString(bytesHex)
if err != nil { if err != nil {
return "", err return "", err
...@@ -310,8 +310,8 @@ func bytesToFormString(t *testing.T, bytesHex string, nb ipld.NodeBuilder) (stri ...@@ -310,8 +310,8 @@ func bytesToFormString(t *testing.T, bytesHex string, nb ipld.NodeBuilder) (stri
return string(str), nil return string(str), nil
} }
// convert a ipld.Node (PBLink) into a map for clean JSON marshalling // convert a ld.Node (PBLink) into a map for clean JSON marshalling
func cleanPBLink(t *testing.T, link ipld.Node) map[string]interface{} { func cleanPBLink(t *testing.T, link ld.Node) map[string]interface{} {
if link == nil { if link == nil {
return nil return nil
} }
...@@ -335,8 +335,8 @@ func cleanPBLink(t *testing.T, link ipld.Node) map[string]interface{} { ...@@ -335,8 +335,8 @@ func cleanPBLink(t *testing.T, link ipld.Node) map[string]interface{} {
return nl return nl
} }
// convert an ipld.Node (PBNode) into a map for clean JSON marshalling // convert an ld.Node (PBNode) into a map for clean JSON marshalling
func cleanPBNode(t *testing.T, node ipld.Node) map[string]interface{} { func cleanPBNode(t *testing.T, node ld.Node) map[string]interface{} {
nn := make(map[string]interface{}) nn := make(map[string]interface{})
data, _ := node.LookupByString("Data") data, _ := node.LookupByString("Data")
if data != nil { if data != nil {
......
/* /*
Package dagpb provides an implementation of the IPLD DAG-PB spec Package dagpb provides an implementation of the LD DAG-PB spec
(https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-pb.md) for (https://gitlab.dms3.io/ld/specs/blob/master/block-layer/codecs/dag-pb.md) for
go-ipld-prime (https://github.com/ipld/go-ipld-prime/). go-ld-prime (https://gitlab.dms3.io/ld/go-ld-prime/).
Use Decode() and Encode() directly, or import this package to have this codec Use Decode() and Encode() directly, or import this package to have this codec
registered into the go-ipld-prime multicodec registry and available from the registered into the go-ld-prime multicodec registry and available from the
cidlink.DefaultLinkSystem. cidlink.DefaultLinkSystem.
Nodes encoded with this codec _must_ conform to the DAG-PB spec. Specifically, Nodes encoded with this codec _must_ conform to the DAG-PB spec. Specifically,
...@@ -22,10 +22,10 @@ they should have the non-optional fields shown in the DAG-PB schema: ...@@ -22,10 +22,10 @@ they should have the non-optional fields shown in the DAG-PB schema:
} }
Use dagpb.Type.PBNode and friends directly for strictness guarantees. Basic Use dagpb.Type.PBNode and friends directly for strictness guarantees. Basic
ipld.Node's will need to have the appropriate fields (and no others) to ld.Node's will need to have the appropriate fields (and no others) to
successfully encode using this codec. successfully encode using this codec.
*/ */
package dagpb package dagpb
//go:generate go run gen.go //go:generate go run gen.go
//go:generate gofmt -w ipldsch_minima.go ipldsch_satisfaction.go ipldsch_types.go //go:generate gofmt -w ldsch_minima.go ldsch_satisfaction.go ldsch_types.go
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
package main package main
// based on https://github.com/ipld/go-ipld-prime-proto/blob/master/gen/main.go // based on https://gitlab.dms3.io/ld/go-ld-prime-proto/blob/master/gen/main.go
import ( import (
"fmt" "fmt"
"os" "os"
"github.com/ipld/go-ipld-prime/schema" "gitlab.dms3.io/ld/go-ld-prime/schema"
gengo "github.com/ipld/go-ipld-prime/schema/gen/go" gengo "gitlab.dms3.io/ld/go-ld-prime/schema/gen/go"
) )
func main() { func main() {
......
...@@ -6,11 +6,6 @@ github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= ...@@ -6,11 +6,6 @@ github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/ipfs/go-cid v0.0.4/go.mod h1:4LLaPOQwmk5z9LBgQnpkivrx8BJjUyGwTXCd5Xfj6+M=
github.com/ipfs/go-cid v0.0.7 h1:ysQJVJA3fNDF1qigJbsSQOdjhVLsOEoPdh0+R97k3jY=
github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I=
github.com/ipld/go-ipld-prime v0.11.0 h1:jD/b/22R7CSL+F9xNffcexs+wO0Ji/TfwXO/TWck+70=
github.com/ipld/go-ipld-prime v0.11.0/go.mod h1:+WIAkokurHmZ/KwzDOMUuoeJgaRQktHtEaLglS3ZeV8=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/klauspost/cpuid/v2 v2.0.4 h1:g0I61F2K2DjRHz1cnxlkNSBIaePVoJIjjnHui8QHbiw= github.com/klauspost/cpuid/v2 v2.0.4 h1:g0I61F2K2DjRHz1cnxlkNSBIaePVoJIjjnHui8QHbiw=
...@@ -26,7 +21,6 @@ github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1 ...@@ -26,7 +21,6 @@ github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM=
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
...@@ -34,18 +28,16 @@ github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp ...@@ -34,18 +28,16 @@ github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp
github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA=
github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4=
github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM=
github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs=
github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk= github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk=
github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc=
github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
github.com/multiformats/go-multihash v0.0.15 h1:hWOPdrNqDjwHDx82vsYGSDZNyktOJJ2dzZJzFkOV1jM= github.com/multiformats/go-multihash v0.0.15 h1:hWOPdrNqDjwHDx82vsYGSDZNyktOJJ2dzZJzFkOV1jM=
github.com/multiformats/go-multihash v0.0.15/go.mod h1:D6aZrWNLFTV/ynMpKsNtB40mJzmCl4jb1alC0OvHiHg= github.com/multiformats/go-multihash v0.0.15/go.mod h1:D6aZrWNLFTV/ynMpKsNtB40mJzmCl4jb1alC0OvHiHg=
github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY=
github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e h1:ZOcivgkkFRnjfoTcGsDq3UQYiBmekwLA+qg0OjyB/ls= github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1 h1:CskT+S6Ay54OwxBGB0R3Rsx4Muto6UnEYTyKJbyRIAI=
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
...@@ -53,6 +45,10 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 ...@@ -53,6 +45,10 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a h1:G++j5e0OC488te356JvdhaM8YS6nMsjLAYF7JxCv07w= github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a h1:G++j5e0OC488te356JvdhaM8YS6nMsjLAYF7JxCv07w=
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
gitlab.dms3.io/dms3/go-cid v0.0.3 h1:5qZ1sl1Bi26naLz7Vsc8fjWcJKX8bR6njt3WPCteXac=
gitlab.dms3.io/dms3/go-cid v0.0.3/go.mod h1:qT/Q1NZD31UnWQ+rwsQgzGrrsQhpq7dYSlXf7ulDgtk=
gitlab.dms3.io/ld/go-ld-prime v0.0.3 h1:M4obYt4Swv8bCheUMy2kmnxP8MUz2QuF4bLiKTNlBgQ=
gitlab.dms3.io/ld/go-ld-prime v0.0.3/go.mod h1:legKOh9xuMrYxCAmU5CfRMbfHSrLmunq4aOUbNAb3hs=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g=
......
package dagpb package dagpb
// Code generated by go-ipld-prime gengo. DO NOT EDIT. // Code generated by go-ld-prime gengo. DO NOT EDIT.
import ( import (
"fmt" "fmt"
"github.com/ipld/go-ipld-prime" "gitlab.dms3.io/ld/go-ld-prime"
"github.com/ipld/go-ipld-prime/schema" "gitlab.dms3.io/ld/go-ld-prime/schema"
) )
const ( const (
...@@ -36,16 +36,16 @@ type _ErrorThunkAssembler struct { ...@@ -36,16 +36,16 @@ type _ErrorThunkAssembler struct {
e error e error
} }
func (ea _ErrorThunkAssembler) BeginMap(_ int64) (ipld.MapAssembler, error) { return nil, ea.e } func (ea _ErrorThunkAssembler) BeginMap(_ int64) (ld.MapAssembler, error) { return nil, ea.e }
func (ea _ErrorThunkAssembler) BeginList(_ int64) (ipld.ListAssembler, error) { return nil, ea.e } func (ea _ErrorThunkAssembler) BeginList(_ int64) (ld.ListAssembler, error) { return nil, ea.e }
func (ea _ErrorThunkAssembler) AssignNull() error { return ea.e } func (ea _ErrorThunkAssembler) AssignNull() error { return ea.e }
func (ea _ErrorThunkAssembler) AssignBool(bool) error { return ea.e } func (ea _ErrorThunkAssembler) AssignBool(bool) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignInt(int64) error { return ea.e } func (ea _ErrorThunkAssembler) AssignInt(int64) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignFloat(float64) error { return ea.e } func (ea _ErrorThunkAssembler) AssignFloat(float64) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignString(string) error { return ea.e } func (ea _ErrorThunkAssembler) AssignString(string) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignBytes([]byte) error { return ea.e } func (ea _ErrorThunkAssembler) AssignBytes([]byte) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignLink(ipld.Link) error { return ea.e } func (ea _ErrorThunkAssembler) AssignLink(ld.Link) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignNode(ipld.Node) error { return ea.e } func (ea _ErrorThunkAssembler) AssignNode(ld.Node) error { return ea.e }
func (ea _ErrorThunkAssembler) Prototype() ipld.NodePrototype { func (ea _ErrorThunkAssembler) Prototype() ld.NodePrototype {
panic(fmt.Errorf("cannot get prototype from error-carrying assembler: already derailed with error: %w", ea.e)) panic(fmt.Errorf("cannot get prototype from error-carrying assembler: already derailed with error: %w", ea.e))
} }
package dagpb package dagpb
// Code generated by go-ipld-prime gengo. DO NOT EDIT. // Code generated by go-ld-prime gengo. DO NOT EDIT.
import ( import (
ipld "github.com/ipld/go-ipld-prime" ld "gitlab.dms3.io/ld/go-ld-prime"
) )
var _ ipld.Node = nil // suppress errors when this dependency is not referenced var _ ld.Node = nil // suppress errors when this dependency is not referenced
// Type is a struct embeding a NodePrototype/Type for every Node implementation in this package. // Type is a struct embeding a NodePrototype/Type for every Node implementation in this package.
// One of its major uses is to start the construction of a value. // One of its major uses is to start the construction of a value.
// You can use it like this: // You can use it like this:
...@@ -38,19 +38,19 @@ type typeSlab struct { ...@@ -38,19 +38,19 @@ type typeSlab struct {
// --- type definitions follow --- // --- type definitions follow ---
// Bytes matches the IPLD Schema type "Bytes". It has bytes kind. // Bytes matches the LD Schema type "Bytes". It has bytes kind.
type Bytes = *_Bytes type Bytes = *_Bytes
type _Bytes struct{ x []byte } type _Bytes struct{ x []byte }
// Int matches the IPLD Schema type "Int". It has int kind. // Int matches the LD Schema type "Int". It has int kind.
type Int = *_Int type Int = *_Int
type _Int struct{ x int64 } type _Int struct{ x int64 }
// Link matches the IPLD Schema type "Link". It has link kind. // Link matches the LD Schema type "Link". It has link kind.
type Link = *_Link type Link = *_Link
type _Link struct{ x ipld.Link } type _Link struct{ x ld.Link }
// PBLink matches the IPLD Schema type "PBLink". It has Struct type-kind, and may be interrogated like map kind. // PBLink matches the LD Schema type "PBLink". It has Struct type-kind, and may be interrogated like map kind.
type PBLink = *_PBLink type PBLink = *_PBLink
type _PBLink struct { type _PBLink struct {
Hash _Link Hash _Link
...@@ -58,19 +58,19 @@ type _PBLink struct { ...@@ -58,19 +58,19 @@ type _PBLink struct {
Tsize _Int__Maybe Tsize _Int__Maybe
} }
// PBLinks matches the IPLD Schema type "PBLinks". It has list kind. // PBLinks matches the LD Schema type "PBLinks". It has list kind.
type PBLinks = *_PBLinks type PBLinks = *_PBLinks
type _PBLinks struct { type _PBLinks struct {
x []_PBLink x []_PBLink
} }
// PBNode matches the IPLD Schema type "PBNode". It has Struct type-kind, and may be interrogated like map kind. // PBNode matches the LD Schema type "PBNode". It has Struct type-kind, and may be interrogated like map kind.
type PBNode = *_PBNode type PBNode = *_PBNode
type _PBNode struct { type _PBNode struct {
Links _PBLinks Links _PBLinks
Data _Bytes__Maybe Data _Bytes__Maybe
} }
// String matches the IPLD Schema type "String". It has string kind. // String matches the LD Schema type "String". It has string kind.
type String = *_String type String = *_String
type _String struct{ x string } type _String struct{ x string }
...@@ -5,9 +5,9 @@ import ( ...@@ -5,9 +5,9 @@ import (
"io" "io"
"sort" "sort"
"github.com/ipfs/go-cid" "gitlab.dms3.io/dms3/go-cid"
ipld "github.com/ipld/go-ipld-prime" ld "gitlab.dms3.io/ld/go-ld-prime"
cidlink "github.com/ipld/go-ipld-prime/linking/cid" cidlink "gitlab.dms3.io/ld/go-ld-prime/linking/cid"
"google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/encoding/protowire"
) )
...@@ -19,14 +19,14 @@ type pbLink struct { ...@@ -19,14 +19,14 @@ type pbLink struct {
hasTsize bool hasTsize bool
} }
// Encode provides an IPLD codec encode interface for DAG-PB data. Provide a // Encode provides an LD codec encode interface for DAG-PB data. Provide a
// conforming Node and a destination for bytes to marshal a DAG-PB IPLD Node. // conforming Node and a destination for bytes to marshal a DAG-PB LD Node.
// The Node must strictly conform to the DAG-PB schema // The Node must strictly conform to the DAG-PB schema
// (https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-pb.md). // (https://gitlab.dms3.io/ld/specs/blob/master/block-layer/codecs/dag-pb.md).
// For safest use, build Nodes using the Type.PBNode type. // For safest use, build Nodes using the Type.PBNode type.
// This function is registered via the go-ipld-prime link loader for multicodec // This function is registered via the go-ld-prime link loader for multicodec
// code 0x70 when this package is invoked via init. // code 0x70 when this package is invoked via init.
func Encode(node ipld.Node, w io.Writer) error { func Encode(node ld.Node, w io.Writer) error {
// 1KiB can be allocated on the stack, and covers most small nodes // 1KiB can be allocated on the stack, and covers most small nodes
// without having to grow the buffer and cause allocations. // without having to grow the buffer and cause allocations.
enc := make([]byte, 0, 1024) enc := make([]byte, 0, 1024)
...@@ -42,7 +42,7 @@ func Encode(node ipld.Node, w io.Writer) error { ...@@ -42,7 +42,7 @@ func Encode(node ipld.Node, w io.Writer) error {
// AppendEncode is like Encode, but it uses a destination buffer directly. // AppendEncode is like Encode, but it uses a destination buffer directly.
// This means less copying of bytes, and if the destination has enough capacity, // This means less copying of bytes, and if the destination has enough capacity,
// fewer allocations. // fewer allocations.
func AppendEncode(enc []byte, inNode ipld.Node) ([]byte, error) { func AppendEncode(enc []byte, inNode ld.Node) ([]byte, error) {
// Wrap in a typed node for some basic schema form checking // Wrap in a typed node for some basic schema form checking
builder := Type.PBNode.NewBuilder() builder := Type.PBNode.NewBuilder()
if err := builder.AssignNode(inNode); err != nil { if err := builder.AssignNode(inNode); err != nil {
......
...@@ -3,15 +3,15 @@ package dagpb ...@@ -3,15 +3,15 @@ package dagpb
import ( import (
"io" "io"
ipld "github.com/ipld/go-ipld-prime" ld "gitlab.dms3.io/ld/go-ld-prime"
cidlink "github.com/ipld/go-ipld-prime/linking/cid" cidlink "gitlab.dms3.io/ld/go-ld-prime/linking/cid"
"github.com/ipld/go-ipld-prime/multicodec" "gitlab.dms3.io/ld/go-ld-prime/multicodec"
"github.com/ipld/go-ipld-prime/traversal" "gitlab.dms3.io/ld/go-ld-prime/traversal"
) )
var ( var (
_ ipld.Decoder = Decode _ ld.Decoder = Decode
_ ipld.Encoder = Encode _ ld.Encoder = Encode
) )
func init() { func init() {
...@@ -22,7 +22,7 @@ func init() { ...@@ -22,7 +22,7 @@ func init() {
// AddSupportToChooser takes an existing node prototype chooser and subs in // AddSupportToChooser takes an existing node prototype chooser and subs in
// PBNode for the dag-pb multicodec code. // PBNode for the dag-pb multicodec code.
func AddSupportToChooser(existing traversal.LinkTargetNodePrototypeChooser) traversal.LinkTargetNodePrototypeChooser { func AddSupportToChooser(existing traversal.LinkTargetNodePrototypeChooser) traversal.LinkTargetNodePrototypeChooser {
return func(lnk ipld.Link, lnkCtx ipld.LinkContext) (ipld.NodePrototype, error) { return func(lnk ld.Link, lnkCtx ld.LinkContext) (ld.NodePrototype, error) {
if lnk, ok := lnk.(cidlink.Link); ok && lnk.Cid.Prefix().Codec == 0x70 { if lnk, ok := lnk.(cidlink.Link); ok && lnk.Cid.Prefix().Codec == 0x70 {
return Type.PBNode, nil return Type.PBNode, nil
} }
...@@ -36,13 +36,13 @@ func AddSupportToChooser(existing traversal.LinkTargetNodePrototypeChooser) trav ...@@ -36,13 +36,13 @@ func AddSupportToChooser(existing traversal.LinkTargetNodePrototypeChooser) trav
// unnecessary to have two supported names for each API. // unnecessary to have two supported names for each API.
// Deprecated: use Decode instead. // Deprecated: use Decode instead.
func Decoder(na ipld.NodeAssembler, r io.Reader) error { return Decode(na, r) } func Decoder(na ld.NodeAssembler, r io.Reader) error { return Decode(na, r) }
// Deprecated: use Decode instead. // Deprecated: use Decode instead.
func Unmarshal(na ipld.NodeAssembler, r io.Reader) error { return Decode(na, r) } func Unmarshal(na ld.NodeAssembler, r io.Reader) error { return Decode(na, r) }
// Deprecated: use Encode instead. // Deprecated: use Encode instead.
func Encoder(inNode ipld.Node, w io.Writer) error { return Encode(inNode, w) } func Encoder(inNode ld.Node, w io.Writer) error { return Encode(inNode, w) }
// Deprecated: use Encode instead. // Deprecated: use Encode instead.
func Marshal(inNode ipld.Node, w io.Writer) error { return Encode(inNode, w) } func Marshal(inNode ld.Node, w io.Writer) error { return Encode(inNode, w) }
...@@ -5,9 +5,9 @@ import ( ...@@ -5,9 +5,9 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"github.com/ipfs/go-cid" "gitlab.dms3.io/dms3/go-cid"
ipld "github.com/ipld/go-ipld-prime" ld "gitlab.dms3.io/ld/go-ld-prime"
cidlink "github.com/ipld/go-ipld-prime/linking/cid" cidlink "gitlab.dms3.io/ld/go-ld-prime/linking/cid"
"google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/encoding/protowire"
) )
...@@ -15,13 +15,13 @@ import ( ...@@ -15,13 +15,13 @@ import (
// malformed data // malformed data
var ErrIntOverflow = fmt.Errorf("protobuf: varint overflow") var ErrIntOverflow = fmt.Errorf("protobuf: varint overflow")
// Decode provides an IPLD codec decode interface for DAG-PB data. Provide a // Decode provides an LD codec decode interface for DAG-PB data. Provide a
// compatible NodeAssembler and a byte source to unmarshal a DAG-PB IPLD Node. // compatible NodeAssembler and a byte source to unmarshal a DAG-PB LD Node.
// Use the NodeAssembler from the PBNode type for safest construction // Use the NodeAssembler from the PBNode type for safest construction
// (Type.PBNode.NewBuilder()). A Map assembler will also work. // (Type.PBNode.NewBuilder()). A Map assembler will also work.
// This function is registered via the go-ipld-prime link loader for multicodec // This function is registered via the go-ld-prime link loader for multicodec
// code 0x70 when this package is invoked via init. // code 0x70 when this package is invoked via init.
func Decode(na ipld.NodeAssembler, in io.Reader) error { func Decode(na ld.NodeAssembler, in io.Reader) error {
var src []byte var src []byte
if buf, ok := in.(interface{ Bytes() []byte }); ok { if buf, ok := in.(interface{ Bytes() []byte }); ok {
src = buf.Bytes() src = buf.Bytes()
...@@ -38,14 +38,14 @@ func Decode(na ipld.NodeAssembler, in io.Reader) error { ...@@ -38,14 +38,14 @@ func Decode(na ipld.NodeAssembler, in io.Reader) error {
// DecodeBytes is like Decode, but it uses an input buffer directly. // DecodeBytes is like Decode, but it uses an input buffer directly.
// Decode will grab or read all the bytes from an io.Reader anyway, so this can // Decode will grab or read all the bytes from an io.Reader anyway, so this can
// save having to copy the bytes or create a bytes.Buffer. // save having to copy the bytes or create a bytes.Buffer.
func DecodeBytes(na ipld.NodeAssembler, src []byte) error { func DecodeBytes(na ld.NodeAssembler, src []byte) error {
remaining := src remaining := src
ma, err := na.BeginMap(2) ma, err := na.BeginMap(2)
if err != nil { if err != nil {
return err return err
} }
var links ipld.ListAssembler var links ld.ListAssembler
haveData := false haveData := false
haveLinks := false haveLinks := false
...@@ -66,7 +66,7 @@ func DecodeBytes(na ipld.NodeAssembler, src []byte) error { ...@@ -66,7 +66,7 @@ func DecodeBytes(na ipld.NodeAssembler, src []byte) error {
// Note that we allow Data and Links to come in either order, // Note that we allow Data and Links to come in either order,
// since the spec defines that decoding "should" accept either form. // since the spec defines that decoding "should" accept either form.
// This is for backwards compatibility with older IPFS data. // This is for backwards compatibility with older dms3 data.
switch fieldNum { switch fieldNum {
case 1: case 1:
...@@ -160,7 +160,7 @@ func DecodeBytes(na ipld.NodeAssembler, src []byte) error { ...@@ -160,7 +160,7 @@ func DecodeBytes(na ipld.NodeAssembler, src []byte) error {
return ma.Finish() return ma.Finish()
} }
func unmarshalLink(remaining []byte, ma ipld.MapAssembler) error { func unmarshalLink(remaining []byte, ma ld.MapAssembler) error {
haveHash := false haveHash := false
haveName := false haveName := false
haveTsize := false haveTsize := false
......
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