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
4aeb40b5
Commit
4aeb40b5
authored
Sep 09, 2016
by
Jeromy Johnson
Committed by
GitHub
Sep 09, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3187 from ipfs/feat/cidv0
Rework go-ipfs to use content IDs version 0
parents
3dc57fc9
22ebb793
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
blocks.go
blocks.go
+8
-2
blocks_test.go
blocks_test.go
+1
-1
No files found.
blocks.go
View file @
4aeb40b5
...
...
@@ -7,15 +7,17 @@ import (
"fmt"
key
"github.com/ipfs/go-ipfs/blocks/key"
mh
"gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash"
u
"gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
cid
"gx/ipfs/QmfSc2xehWmWLnwwYR91Y8QF4xdASypTFVknutoKQS3GHp/go-cid"
)
var
ErrWrongHash
=
errors
.
New
(
"data did not match given hash!"
)
type
Block
interface
{
Multihash
()
mh
.
Multihash
Data
()
[]
byte
Raw
Data
()
[]
byte
Key
()
key
.
Key
String
()
string
Loggable
()
map
[
string
]
interface
{}
...
...
@@ -49,10 +51,14 @@ func (b *BasicBlock) Multihash() mh.Multihash {
return
b
.
multihash
}
func
(
b
*
BasicBlock
)
Data
()
[]
byte
{
func
(
b
*
BasicBlock
)
Raw
Data
()
[]
byte
{
return
b
.
data
}
func
(
b
*
BasicBlock
)
Cid
()
*
cid
.
Cid
{
return
cid
.
NewCidV0
(
b
.
multihash
)
}
// Key returns the block's Multihash as a Key value.
func
(
b
*
BasicBlock
)
Key
()
key
.
Key
{
return
key
.
Key
(
b
.
multihash
)
...
...
blocks_test.go
View file @
4aeb40b5
...
...
@@ -25,7 +25,7 @@ func TestData(t *testing.T) {
data
:=
[]
byte
(
"some data"
)
block
:=
NewBlock
(
data
)
if
!
bytes
.
Equal
(
block
.
Data
(),
data
)
{
if
!
bytes
.
Equal
(
block
.
Raw
Data
(),
data
)
{
t
.
Error
(
"data is wrong"
)
}
}
...
...
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