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
dms3
go-dms3-ds-help
Commits
0c9f4a7c
Commit
0c9f4a7c
authored
5 years ago
by
Hector Sanjuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace DsKeyToCidV1Raw() with DsKeyToCidV1()
Allow passing in whatever codec type the user wants
parent
48143f3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
key.go
key.go
+4
-3
key_test.go
key_test.go
+1
-1
No files found.
key.go
View file @
0c9f4a7c
...
...
@@ -40,11 +40,12 @@ func DsKeyToMultihash(dsKey datastore.Key) (mh.Multihash, error) {
}
// DsKeyToCidV1Raw converts the given Key (which should be a raw multihash
// key) to a Cid V1 of raw type.
func
DsKeyToCidV1Raw
(
dsKey
datastore
.
Key
)
(
cid
.
Cid
,
error
)
{
// key) to a Cid V1 of the given type (see
// https://godoc.org/github.com/ipfs/go-cid#pkg-constants).
func
DsKeyToCidV1
(
dsKey
datastore
.
Key
,
codecType
uint64
)
(
cid
.
Cid
,
error
)
{
hash
,
err
:=
DsKeyToMultihash
(
dsKey
)
if
err
!=
nil
{
return
cid
.
Cid
{},
err
}
return
cid
.
NewCidV1
(
c
id
.
Raw
,
hash
),
nil
return
cid
.
NewCidV1
(
c
odecType
,
hash
),
nil
}
This diff is collapsed.
Click to expand it.
key_test.go
View file @
0c9f4a7c
...
...
@@ -17,7 +17,7 @@ func TestKey(t *testing.T) {
t
.
Fatal
(
"should have parsed the same multihash"
)
}
c2
,
err
:=
DsKeyToCidV1
Raw
(
dsKey
)
c2
,
err
:=
DsKeyToCidV1
(
dsKey
,
cid
.
Raw
)
if
err
!=
nil
||
c
.
Equals
(
c2
)
||
c2
.
Type
()
!=
cid
.
Raw
||
c2
.
Version
()
!=
1
{
t
.
Fatal
(
"should have been converted to CIDv1-raw"
)
}
...
...
This diff is collapsed.
Click to expand it.
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