Commit c9551347 authored by tavit ohanian's avatar tavit ohanian

initial port

parent 142cad54
// Package cid implements the Content-IDentifiers specification
// (https://github.com/ipld/cid) in Go. CIDs are
// (https://gitlab.dms3.io/dms3/public/dms3ld/cid) in Go. CIDs are
// self-describing content-addressed identifiers useful for
// distributed information systems. CIDs are used in the IPFS
// (https://ipfs.io) project ecosystem.
// distributed information systems. CIDs are used in the DMS3
// (https://dms3.io) project ecosystem.
//
// CIDs have two major versions. A CIDv0 corresponds to a multihash of type
// DagProtobuf, is deprecated and exists for compatibility reasons. Usually,
......@@ -154,8 +154,8 @@ func tryNewCidV0(mhash mh.Multihash) (Cid, error) {
}
// NewCidV0 returns a Cid-wrapped multihash.
// They exist to allow IPFS to work with Cids while keeping
// compatibility with the plain-multihash format used used in IPFS.
// They exist to allow DMS3 to work with Cids while keeping
// compatibility with the plain-multihash format used used in DMS3.
// NewCidV1 should be used preferentially.
//
// Panics if the multihash isn't sha2-256.
......@@ -211,8 +211,8 @@ func (c Cid) Defined() bool {
func Parse(v interface{}) (Cid, error) {
switch v2 := v.(type) {
case string:
if strings.Contains(v2, "/ipfs/") {
return Decode(strings.Split(v2, "/ipfs/")[1])
if strings.Contains(v2, "/dms3/") {
return Decode(strings.Split(v2, "/dms3/")[1])
}
return Decode(v2)
case []byte:
......@@ -497,8 +497,8 @@ func (c *Cid) UnmarshalJSON(b []byte) error {
//
// { "/": "<cid-string>" }
//
// Note that this formatting comes from the IPLD specification
// (https://github.com/ipld/specs/tree/master/ipld)
// Note that this formatting comes from the DMS3LD specification
// (https://github.com/dms3ld/specs/tree/master/dms3ld)
func (c Cid) MarshalJSON() ([]byte, error) {
if !c.Defined() {
return []byte("null"), nil
......@@ -512,7 +512,7 @@ func (c Cid) KeyString() string {
}
// Loggable returns a Loggable (as defined by
// https://godoc.org/github.com/ipfs/go-log).
// https://godoc.org/gitlab.dms3.io/dms3/public/go-log).
func (c Cid) Loggable() map[string]interface{} {
return map[string]interface{}{
"cid": c,
......
......@@ -80,7 +80,7 @@ func TestTableForV0(t *testing.T) {
func TestPrefixSum(t *testing.T) {
// Test creating CIDs both manually and with Prefix.
// Tests: https://github.com/ipfs/go-cid/issues/83
// Tests: https://gitlab.dms3.io/dms3/public/go-cid/issues/83
for _, hashfun := range []uint64{
mh.ID, mh.SHA3, mh.SHA2_256,
} {
......@@ -516,9 +516,9 @@ func TestParse(t *testing.T) {
[]interface{}{NewCidV0(h).Bytes(), theHash},
[]interface{}{h, theHash},
[]interface{}{theHash, theHash},
[]interface{}{"/ipfs/" + theHash, theHash},
[]interface{}{"https://ipfs.io/ipfs/" + theHash, theHash},
[]interface{}{"http://localhost:8080/ipfs/" + theHash, theHash},
[]interface{}{"/dms3/" + theHash, theHash},
[]interface{}{"https://dms3.io/dms3/" + theHash, theHash},
[]interface{}{"http://localhost:8180/dms3/" + theHash, theHash},
}
assert := func(arg interface{}, expected string) error {
......
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