Commit ac985170 authored by tavit ohanian's avatar tavit ohanian

initial port

parent 5eca8a5a
Pipeline #279 passed with stages
in 32 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-ipld-format
go-dms3ld-format
==================
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
......@@ -7,7 +7,7 @@ go-ipld-format
[![Coverage Status](https://codecov.io/gh/ipfs/go-ipld-format/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-ipld-format/branch/master)
[![Travis CI](https://travis-ci.org/ipfs/go-ipld-format.svg?branch=master)](https://travis-ci.org/ipfs/go-ipld-format)
> go-ipld-format is a set of interfaces that a type needs to implement in order to be a part of the ipld merkle-forest.
> go-dms3ld-format is a set of interfaces that a type needs to implement in order to be a part of the dms3ld merkle-forest.
## Lead Maintainer
......
......@@ -5,11 +5,11 @@ import (
"errors"
"runtime"
cid "github.com/ipfs/go-cid"
cid "gitlab.dms3.io/dms3/public/go-cid"
)
// parallelBatchCommits is the number of batch commits that can be in-flight before blocking.
// TODO(ipfs/go-ipfs#4299): Experiment with multiple datastores, storage
// TODO(dms3/go-dms3#4299): Experiment with multiple datastores, storage
// devices, and CPUs to find the right value/formula.
var parallelCommits = runtime.NumCPU()
......
......@@ -5,7 +5,7 @@ import (
"sync"
"testing"
cid "github.com/ipfs/go-cid"
cid "gitlab.dms3.io/dms3/public/go-cid"
)
// Test dag
......
......@@ -4,7 +4,7 @@ import (
"fmt"
"sync"
blocks "github.com/ipfs/go-block-format"
blocks "gitlab.dms3.io/dms3/public/go-block-format"
)
// DecodeBlockFunc functions decode blocks into nodes.
......
......@@ -4,9 +4,9 @@ import (
"errors"
"testing"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
mh "github.com/multiformats/go-multihash"
blocks "gitlab.dms3.io/dms3/public/go-block-format"
cid "gitlab.dms3.io/dms3/public/go-cid"
)
func init() {
......
......@@ -3,7 +3,7 @@ package format
import (
"context"
cid "github.com/ipfs/go-cid"
cid "gitlab.dms3.io/dms3/public/go-cid"
)
// GetLinks returns the CIDs of the children of the given node. Prefer this
......
......@@ -2,9 +2,10 @@ package format
import (
"context"
"github.com/ipfs/go-cid"
mh "github.com/multiformats/go-multihash"
"testing"
mh "github.com/multiformats/go-multihash"
"gitlab.dms3.io/dms3/public/go-cid"
)
type TestNode struct {
......
......@@ -4,9 +4,9 @@ import (
"context"
"fmt"
blocks "github.com/ipfs/go-block-format"
blocks "gitlab.dms3.io/dms3/public/go-block-format"
cid "github.com/ipfs/go-cid"
cid "gitlab.dms3.io/dms3/public/go-cid"
)
type Resolver interface {
......@@ -19,7 +19,7 @@ type Resolver interface {
Tree(path string, depth int) []string
}
// Node is the base interface all IPLD nodes must implement.
// Node is the base interface all DMS3LD nodes must implement.
//
// Nodes are **Immutable** and all methods defined on the interface are
// **Thread Safe**.
......@@ -44,7 +44,7 @@ type Node interface {
Size() (uint64, error)
}
// Link represents an IPFS Merkle DAG Link between Nodes.
// Link represents an DMS3 Merkle DAG Link between Nodes.
type Link struct {
// utf string name. should be unique per object
Name string // utf8
......
......@@ -4,8 +4,8 @@ import (
"errors"
"testing"
cid "github.com/ipfs/go-cid"
mh "github.com/multiformats/go-multihash"
cid "gitlab.dms3.io/dms3/public/go-cid"
)
type EmptyNode struct{}
......
......@@ -16,15 +16,46 @@ github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16 h1:5W7KhL8HVF3XCFOweFD3BNESdnO8ewyYTFT2R+/b8FQ=
github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771 h1:MHkK1uRtFbVqvAgvWxafZe54+5uBxLluGylDiKgdhwo=
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/mr-tron/base58 v1.1.0 h1:Y51FGVJ91WBqCEabAi5OPUz38eAx8DakuAm5svLcsfQ=
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc=
github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI=
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/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM=
github.com/multiformats/go-multibase v0.0.1 h1:PN9/v21eLywrFWdFNsFKaU04kLJzuYzmrJR+ubhT9qA=
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/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc=
github.com/multiformats/go-multihash v0.0.1 h1:HHwN1K12I+XllBCrqKnhX949Orn4oawPkegHMu2vDqQ=
github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U=
github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
github.com/multiformats/go-multihash v0.0.14 h1:QoBceQYQQtNUuf6s7wHxnE2c8bhbMqhfGzNI032se/I=
github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
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/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
gitlab.dms3.io/dms3/public/go-block-format v0.0.1 h1:PQ6+E7zY6kUIHET86uJTQHTTj4Z9ZNfP7w281ZdExgk=
gitlab.dms3.io/dms3/public/go-block-format v0.0.1/go.mod h1:xlvtW/OF72rOzLa2RVWXX2Uw18qTAWTQEs/Xp7SCnuY=
gitlab.dms3.io/dms3/public/go-cid v0.0.0 h1:DKvGTYv5GqSEeVLfQAHBbsFZuWCZFNK5BHdBFykF45E=
gitlab.dms3.io/dms3/public/go-cid v0.0.1 h1:qs4dtkDigcLGY/58dIZaFjKLt+orrTcmTBvtqaM3570=
gitlab.dms3.io/dms3/public/go-cid v0.0.1/go.mod h1:GQw3gc4CSrFY+aX6M+OBQDlg0p5/eQJoRrayaZzkAOQ=
gitlab.dms3.io/dms3/public/go-dms3-util v0.0.1 h1:Gd+kJl1Rc+ZEUb9CIS1ZctQnF9G1oruNFyxUC//QBUQ=
gitlab.dms3.io/dms3/public/go-dms3-util v0.0.1/go.mod h1:ymlwtzTNMq8Ug+gVtPAMxXKCKTXwXJAzXS+SUihfKgo=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXTqk7U7zPQCb+T4rbU9ZEoU=
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190219092855-153ac476189d h1:Z0Ahzd7HltpJtjAHHxX8QFP3j1yYgiuvjbjRzDj/KH0=
golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
......@@ -4,7 +4,7 @@ import (
"context"
"fmt"
cid "github.com/ipfs/go-cid"
cid "gitlab.dms3.io/dms3/public/go-cid"
)
var ErrNotFound = fmt.Errorf("merkledag: not found")
......@@ -43,14 +43,14 @@ type NodeAdder interface {
type LinkGetter interface {
NodeGetter
// TODO(ipfs/go-ipld-format#9): This should return []cid.Cid
// TODO(dms3/go-dms3ld-format#9): This should return []cid.Cid
// GetLinks returns the children of the node refered to by the given
// CID.
GetLinks(ctx context.Context, nd cid.Cid) ([]*Link, error)
}
// DAGService is an IPFS Merkle DAG service.
// DAGService is an DMS3 Merkle DAG service.
type DAGService interface {
NodeGetter
NodeAdder
......
......@@ -3,12 +3,12 @@ package format
import (
"context"
cid "github.com/ipfs/go-cid"
cid "gitlab.dms3.io/dms3/public/go-cid"
)
// NavigableIPLDNode implements the `NavigableNode` interface wrapping
// an IPLD `Node` and providing support for node promises.
type NavigableIPLDNode struct {
// NavigableDMS3LDNode implements the `NavigableNode` interface wrapping
// an DMS3LD `Node` and providing support for node promises.
type NavigableDMS3LDNode struct {
node Node
// The CID of each child of the node.
......@@ -24,10 +24,10 @@ type NavigableIPLDNode struct {
// to be replicated (the entire DAG will use the same `NodeGetter`).
}
// NewNavigableIPLDNode returns a `NavigableIPLDNode` wrapping the provided
// NewNavigableDMS3LDNode returns a `NavigableDMS3LDNode` wrapping the provided
// `node`.
func NewNavigableIPLDNode(node Node, nodeGetter NodeGetter) *NavigableIPLDNode {
nn := &NavigableIPLDNode{
func NewNavigableDMS3LDNode(node Node, nodeGetter NodeGetter) *NavigableDMS3LDNode {
nn := &NavigableDMS3LDNode{
node: node,
nodeGetter: nodeGetter,
}
......@@ -41,7 +41,7 @@ func NewNavigableIPLDNode(node Node, nodeGetter NodeGetter) *NavigableIPLDNode {
// FetchChild implements the `NavigableNode` interface using node promises
// to preload the following child nodes to `childIndex` leaving them ready
// for subsequent `FetchChild` calls.
func (nn *NavigableIPLDNode) FetchChild(ctx context.Context, childIndex uint) (NavigableNode, error) {
func (nn *NavigableDMS3LDNode) FetchChild(ctx context.Context, childIndex uint) (NavigableNode, error) {
// This function doesn't check that `childIndex` is valid, that's
// the `Walker` responsibility.
......@@ -76,7 +76,7 @@ func (nn *NavigableIPLDNode) FetchChild(ctx context.Context, childIndex uint) (N
return nil, err
}
return NewNavigableIPLDNode(child, nn.nodeGetter), nil
return NewNavigableDMS3LDNode(child, nn.nodeGetter), nil
}
// Number of nodes to preload every time a child is requested.
......@@ -86,7 +86,7 @@ const preloadSize = 10
// Preload at most `preloadSize` child nodes from `beg` through promises
// created using this `ctx`.
func (nn *NavigableIPLDNode) preload(ctx context.Context, beg uint) {
func (nn *NavigableDMS3LDNode) preload(ctx context.Context, beg uint) {
end := beg + preloadSize
if end >= uint(len(nn.childCIDs)) {
end = uint(len(nn.childCIDs))
......@@ -101,7 +101,7 @@ func (nn *NavigableIPLDNode) preload(ctx context.Context, beg uint) {
//
// TODO: Include `preload` into the beginning of this function?
// (And collapse the two calls in `FetchChild`).
func (nn *NavigableIPLDNode) getPromiseValue(ctx context.Context, childIndex uint) (Node, error) {
func (nn *NavigableDMS3LDNode) getPromiseValue(ctx context.Context, childIndex uint) (Node, error) {
value, err := nn.childPromises[childIndex].Get(ctx)
nn.childPromises[childIndex] = nil
return value, err
......@@ -118,32 +118,32 @@ func getLinkCids(node Node) []cid.Cid {
return out
}
// GetIPLDNode returns the IPLD `Node` wrapped into this structure.
func (nn *NavigableIPLDNode) GetIPLDNode() Node {
// GetDMS3LDNode returns the DMS3LD `Node` wrapped into this structure.
func (nn *NavigableDMS3LDNode) GetDMS3LDNode() Node {
return nn.node
}
// ChildTotal implements the `NavigableNode` returning the number
// of links (of child nodes) in this node.
func (nn *NavigableIPLDNode) ChildTotal() uint {
return uint(len(nn.GetIPLDNode().Links()))
func (nn *NavigableDMS3LDNode) ChildTotal() uint {
return uint(len(nn.GetDMS3LDNode().Links()))
}
// ExtractIPLDNode is a helper function that takes a `NavigableNode`
// and returns the IPLD `Node` wrapped inside. Used in the `Visitor`
// ExtractDMS3LDNode is a helper function that takes a `NavigableNode`
// and returns the DMS3LD `Node` wrapped inside. Used in the `Visitor`
// function.
// TODO: Check for errors to avoid a panic?
func ExtractIPLDNode(node NavigableNode) Node {
return node.GetIPLDNode()
func ExtractDMS3LDNode(node NavigableNode) Node {
return node.GetDMS3LDNode()
}
// TODO: `Cleanup` is not supported at the moment in the `Walker`.
//
// Called in `Walker.up()` when the node is not part of the path anymore.
//func (nn *NavigableIPLDNode) Cleanup() {
//func (nn *NavigableDMS3LDNode) Cleanup() {
// // TODO: Ideally this would be the place to issue a context `cancel()`
// // but since the DAG reader uses multiple contexts in the same session
// // (through `Read` and `CtxReadFull`) we would need to store an array
// // with the multiple contexts in `NavigableIPLDNode` with its corresponding
// // with the multiple contexts in `NavigableDMS3LDNode` with its corresponding
// // cancel functions.
//}
......@@ -16,7 +16,7 @@ import (
// read data from those nodes and, optionally, direct the movement of
// the Walker by calling `Pause` (to stop traversing and return) or
// `NextChild` (to skip a child and its descendants). See the DAG reader
// in `github.com/ipfs/go-unixfs/io/dagreader.go` for a usage example.
// in `gitlab.dms3.io/dms3/public/go-unixfs/io/dagreader.go` for a usage example.
// TODO: This example isn't merged yet.
type Walker struct {
......@@ -64,7 +64,7 @@ type Walker struct {
// Used to pass information from the central `Walker` structure to the
// distributed `NavigableNode`s (to have a centralized configuration
// structure to control the behavior of all of them), e.g., to tell
// the `NavigableIPLDNode` which context should be used to load node
// the `NavigableDMS3LDNode` which context should be used to load node
// promises (but this could later be used in more elaborate ways).
ctx context.Context
}
......@@ -116,8 +116,8 @@ type NavigableNode interface {
// ChildTotal returns the number of children of the `ActiveNode`.
ChildTotal() uint
// GetIPLDNode returns actual IPLD Node
GetIPLDNode() Node
// GetDMS3LDNode returns actual DMS3LD Node
GetDMS3LDNode() Node
// TODO: Evaluate providing the `Cleanup` and `Reset` methods.
......
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