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-merkledag
Commits
70cb3dd8
Commit
70cb3dd8
authored
Aug 10, 2018
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Prefix() and SetPrefix() to CidPrefix() and SetCidPrefix().
parent
ff4fe8a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
+13
-14
coding.go
coding.go
+2
-2
node.go
node.go
+7
-7
raw.go
raw.go
+4
-5
No files found.
coding.go
View file @
70cb3dd8
...
...
@@ -93,7 +93,7 @@ func (n *ProtoNode) EncodeProtobuf(force bool) ([]byte, error) {
}
if
n
.
cached
==
nil
{
c
,
err
:=
n
.
Prefix
()
.
Sum
(
n
.
encoded
)
c
,
err
:=
n
.
CidBuilder
()
.
Sum
(
n
.
encoded
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -131,7 +131,7 @@ func DecodeProtobufBlock(b blocks.Block) (ipld.Node, error) {
}
decnd
.
cached
=
c
decnd
.
Set
Prefix
(
c
.
Prefix
())
decnd
.
Set
CidBuilder
(
c
.
Prefix
())
return
decnd
,
nil
}
...
...
node.go
View file @
70cb3dd8
...
...
@@ -63,21 +63,21 @@ func PrefixForCidVersion(version int) (cid.Prefix, error) {
}
}
//
Prefix
returns the CID
Prefix
for this ProtoNode, it is never nil
func
(
n
*
ProtoNode
)
Prefix
()
cid
.
Builder
{
//
CidBuilder
returns the CID
Builder
for this ProtoNode, it is never nil
func
(
n
*
ProtoNode
)
CidBuilder
()
cid
.
Builder
{
if
n
.
builder
==
nil
{
n
.
builder
=
v0CidPrefix
}
return
n
.
builder
}
// Set
Prefix
sets the CID
prefix
if it is non nil, if
prefix is
nil then
// i
t
reset
s it
the default value
func
(
n
*
ProtoNode
)
Set
Prefix
(
prefix
cid
.
Builder
)
{
if
prefix
==
nil
{
// Set
CidBuilder
sets the CID
builder
if it is non nil, if nil then
it
// i
s
reset
to
the default value
func
(
n
*
ProtoNode
)
Set
CidBuilder
(
builder
cid
.
Builder
)
{
if
builder
==
nil
{
n
.
builder
=
v0CidPrefix
}
else
{
n
.
builder
=
prefix
.
WithCodec
(
cid
.
DagProtobuf
)
n
.
builder
=
builder
.
WithCodec
(
cid
.
DagProtobuf
)
n
.
encoded
=
nil
n
.
cached
=
nil
}
...
...
raw.go
View file @
70cb3dd8
...
...
@@ -34,11 +34,10 @@ func DecodeRawBlock(block blocks.Block) (ipld.Node, error) {
var
_
ipld
.
DecodeBlockFunc
=
DecodeRawBlock
// NewRawNodeWPrefix creates a RawNode with the hash function
// specified in prefix.
func
NewRawNodeWPrefix
(
data
[]
byte
,
prefix
cid
.
Builder
)
(
*
RawNode
,
error
)
{
prefix
=
prefix
.
WithCodec
(
cid
.
Raw
)
c
,
err
:=
prefix
.
Sum
(
data
)
// NewRawNodeWPrefix creates a RawNode using the provided cid builder
func
NewRawNodeWPrefix
(
data
[]
byte
,
builder
cid
.
Builder
)
(
*
RawNode
,
error
)
{
builder
=
builder
.
WithCodec
(
cid
.
Raw
)
c
,
err
:=
builder
.
Sum
(
data
)
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