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
823a0716
Commit
823a0716
authored
Mar 18, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix error style
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
6598da30
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
coding.go
coding.go
+5
-5
merkledag.go
merkledag.go
+1
-1
merkledag_test.go
merkledag_test.go
+1
-1
No files found.
coding.go
View file @
823a0716
...
...
@@ -21,7 +21,7 @@ import (
func
(
n
*
ProtoNode
)
unmarshal
(
encoded
[]
byte
)
error
{
var
pbn
pb
.
PBNode
if
err
:=
pbn
.
Unmarshal
(
encoded
);
err
!=
nil
{
return
fmt
.
Errorf
(
"
U
nmarshal failed. %v"
,
err
)
return
fmt
.
Errorf
(
"
u
nmarshal failed. %v"
,
err
)
}
pbnl
:=
pbn
.
GetLinks
()
...
...
@@ -30,7 +30,7 @@ func (n *ProtoNode) unmarshal(encoded []byte) error {
n
.
links
[
i
]
=
&
ipld
.
Link
{
Name
:
l
.
GetName
(),
Size
:
l
.
GetTsize
()}
c
,
err
:=
cid
.
Cast
(
l
.
GetHash
())
if
err
!=
nil
{
return
fmt
.
Errorf
(
"
L
ink hash #%d is not valid multihash. %v"
,
i
,
err
)
return
fmt
.
Errorf
(
"
l
ink hash #%d is not valid multihash. %v"
,
i
,
err
)
}
n
.
links
[
i
]
.
Cid
=
c
}
...
...
@@ -47,7 +47,7 @@ func (n *ProtoNode) Marshal() ([]byte, error) {
pbn
:=
n
.
getPBNode
()
data
,
err
:=
pbn
.
Marshal
()
if
err
!=
nil
{
return
data
,
fmt
.
Errorf
(
"
M
arshal failed. %v"
,
err
)
return
data
,
fmt
.
Errorf
(
"
m
arshal failed. %v"
,
err
)
}
return
data
,
nil
}
...
...
@@ -123,9 +123,9 @@ func DecodeProtobufBlock(b blocks.Block) (ipld.Node, error) {
decnd
,
err
:=
DecodeProtobuf
(
b
.
RawData
())
if
err
!=
nil
{
if
strings
.
Contains
(
err
.
Error
(),
"Unmarshal failed"
)
{
return
nil
,
fmt
.
Errorf
(
"
T
he block referred to by '%s' was not a valid merkledag node"
,
c
)
return
nil
,
fmt
.
Errorf
(
"
t
he block referred to by '%s' was not a valid merkledag node"
,
c
)
}
return
nil
,
fmt
.
Errorf
(
"
F
ailed to decode Protocol Buffers: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"
f
ailed to decode Protocol Buffers: %v"
,
err
)
}
decnd
.
cached
=
c
...
...
merkledag.go
View file @
823a0716
...
...
@@ -74,7 +74,7 @@ func (n *dagService) Get(ctx context.Context, c *cid.Cid) (ipld.Node, error) {
if
err
==
bserv
.
ErrNotFound
{
return
nil
,
ipld
.
ErrNotFound
}
return
nil
,
fmt
.
Errorf
(
"
F
ailed to get block for %s: %v"
,
c
,
err
)
return
nil
,
fmt
.
Errorf
(
"
f
ailed to get block for %s: %v"
,
c
,
err
)
}
return
ipld
.
Decode
(
b
)
...
...
merkledag_test.go
View file @
823a0716
...
...
@@ -239,7 +239,7 @@ func runBatchFetchTest(t *testing.T, read io.Reader) {
}
if
!
bytes
.
Equal
(
datagot
,
expected
)
{
errs
<-
errors
.
New
(
"
G
ot bad data back
!
"
)
errs
<-
errors
.
New
(
"
g
ot bad data back"
)
}
}(
i
)
}
...
...
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