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-block-format
Commits
7e736763
Commit
7e736763
authored
Oct 29, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address comments from PR
parent
d1dd0be3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
blocks.go
blocks.go
+11
-0
No files found.
blocks.go
View file @
7e736763
package
blocks
package
blocks
import
(
import
(
"errors"
"fmt"
"fmt"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
...
@@ -18,6 +19,16 @@ func NewBlock(data []byte) *Block {
...
@@ -18,6 +19,16 @@ func NewBlock(data []byte) *Block {
return
&
Block
{
Data
:
data
,
Multihash
:
u
.
Hash
(
data
)}
return
&
Block
{
Data
:
data
,
Multihash
:
u
.
Hash
(
data
)}
}
}
func
NewBlockWithHash
(
data
[]
byte
,
h
mh
.
Multihash
)
(
*
Block
,
error
)
{
if
u
.
Debug
{
chk
:=
u
.
Hash
(
data
)
if
string
(
chk
)
!=
string
(
h
)
{
return
nil
,
errors
.
New
(
"Data did not match given hash!"
)
}
}
return
&
Block
{
Data
:
data
,
Multihash
:
h
},
nil
}
// Key returns the block's Multihash as a Key value.
// Key returns the block's Multihash as a Key value.
func
(
b
*
Block
)
Key
()
u
.
Key
{
func
(
b
*
Block
)
Key
()
u
.
Key
{
return
u
.
Key
(
b
.
Multihash
)
return
u
.
Key
(
b
.
Multihash
)
...
...
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