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
Commits
8a47786c
Commit
8a47786c
authored
Mar 31, 2017
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hamt: support using CIDv1 by allowing the prefix to be set
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
parent
076d0bd9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
test/sharness/t0260-sharding-flag.sh
test/sharness/t0260-sharding-flag.sh
+19
-0
unixfs/hamt/hamt.go
unixfs/hamt/hamt.go
+7
-0
unixfs/io/dirbuilder.go
unixfs/io/dirbuilder.go
+3
-4
No files found.
test/sharness/t0260-sharding-flag.sh
View file @
8a47786c
...
...
@@ -55,4 +55,23 @@ test_expect_success "sharded and unsharded output look the same" '
test_cmp sharded_out unsharded_out
'
test_add_large_dir_v1
()
{
exphash
=
"
$1
"
test_expect_success
"ipfs add (CIDv1) on very large directory succeeds"
'
ipfs add -r -q --cid-version=1 testdata | tail -n1 > sharddir_out &&
echo "$exphash" > sharddir_exp &&
test_cmp sharddir_exp sharddir_out
'
}
# this hash implies both the directory and the leaf entries are CIDv1
SHARDEDV1
=
"zdj7WX91spg4DsnNpvoBLjyjXUGgcTTWavygBbSifpmJdgPUA"
test_add_large_dir_v1
"
$SHARDEDV1
"
test_launch_ipfs_daemon
test_add_large_dir_v1
"
$SHARDEDV1
"
test_kill_ipfs_daemon
test_done
unixfs/hamt/hamt.go
View file @
8a47786c
...
...
@@ -31,6 +31,7 @@ import (
format
"github.com/ipfs/go-ipfs/unixfs"
upb
"github.com/ipfs/go-ipfs/unixfs/pb"
cid
"gx/ipfs/QmYhQaCYEcaPPjxJX7YcPcVKkQfRy6sJ7B3XmGFk82XYdQ/go-cid"
proto
"gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
node
"gx/ipfs/Qmb3Hm9QDFmfYuET4pu7Kyg8JV78jFa1nvZx5vnCZsK4ck/go-ipld-format"
"gx/ipfs/QmfJHywXQu98UeZtGJBQrPAR6AtmDjjbe3qjTo9piXHPnx/murmur3"
...
...
@@ -50,6 +51,7 @@ type HamtShard struct {
tableSize
int
tableSizeLg2
int
prefix
*
cid
.
Prefix
hashFunc
uint64
prefixPadStr
string
...
...
@@ -123,9 +125,14 @@ func NewHamtFromDag(dserv dag.DAGService, nd node.Node) (*HamtShard, error) {
return
ds
,
nil
}
func
(
ds
*
HamtShard
)
SetPrefix
(
prefix
*
cid
.
Prefix
)
{
ds
.
prefix
=
prefix
}
// Node serializes the HAMT structure into a merkledag node with unixfs formatting
func
(
ds
*
HamtShard
)
Node
()
(
node
.
Node
,
error
)
{
out
:=
new
(
dag
.
ProtoNode
)
out
.
SetPrefix
(
ds
.
prefix
)
// TODO: optimized 'for each set bit'
for
i
:=
0
;
i
<
ds
.
tableSize
;
i
++
{
...
...
unixfs/io/dirbuilder.go
View file @
8a47786c
...
...
@@ -85,10 +85,9 @@ func (d *Directory) SetPrefix(prefix *cid.Prefix) {
if
d
.
dirnode
!=
nil
{
d
.
dirnode
.
SetPrefix
(
prefix
)
}
// FIXME: Should we do this? -- kevina
//if d.shard != nil {
// d.shard.SetPrefix(prefix)
//}
if
d
.
shard
!=
nil
{
d
.
shard
.
SetPrefix
(
prefix
)
}
}
// AddChild adds a (name, key)-pair to the root node.
...
...
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