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-unixfs
Commits
e8ed89ce
Commit
e8ed89ce
authored
Jan 25, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make code-climate happier
License: MIT Signed-off-by:
Steven Allen
<
steven@stebalien.com
>
parent
3ef1c87d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
0 deletions
+10
-0
hamt/hamt.go
hamt/hamt.go
+2
-0
io/dirbuilder.go
io/dirbuilder.go
+2
-0
io/pbdagreader.go
io/pbdagreader.go
+1
-0
test/utils.go
test/utils.go
+5
-0
No files found.
hamt/hamt.go
View file @
e8ed89ce
...
...
@@ -66,6 +66,7 @@ type child interface {
Label
()
string
}
// NewHamtShard creates a new, empty HAMT shard with the given size.
func
NewHamtShard
(
dserv
node
.
DAGService
,
size
int
)
(
*
HamtShard
,
error
)
{
ds
,
err
:=
makeHamtShard
(
dserv
,
size
)
if
err
!=
nil
{
...
...
@@ -93,6 +94,7 @@ func makeHamtShard(ds node.DAGService, size int) (*HamtShard, error) {
},
nil
}
// NewHamtFromDag creates new a HAMT shard from the given DAG.
func
NewHamtFromDag
(
dserv
node
.
DAGService
,
nd
node
.
Node
)
(
*
HamtShard
,
error
)
{
pbnd
,
ok
:=
nd
.
(
*
dag
.
ProtoNode
)
if
!
ok
{
...
...
io/dirbuilder.go
View file @
e8ed89ce
...
...
@@ -51,6 +51,8 @@ func NewDirectory(dserv node.DAGService) *Directory {
// ErrNotADir implies that the given node was not a unixfs directory
var
ErrNotADir
=
fmt
.
Errorf
(
"merkledag node was not a directory or shard"
)
// NewDirectoryFromNode loads a unixfs directory from the given IPLD node and
// DAGService.
func
NewDirectoryFromNode
(
dserv
node
.
DAGService
,
nd
node
.
Node
)
(
*
Directory
,
error
)
{
pbnd
,
ok
:=
nd
.
(
*
mdag
.
ProtoNode
)
if
!
ok
{
...
...
io/pbdagreader.go
View file @
e8ed89ce
...
...
@@ -50,6 +50,7 @@ type pbDagReader struct {
var
_
DagReader
=
(
*
pbDagReader
)(
nil
)
// NewPBFileReader constructs a new PBFileReader.
func
NewPBFileReader
(
ctx
context
.
Context
,
n
*
mdag
.
ProtoNode
,
pb
*
ftpb
.
Data
,
serv
node
.
DAGService
)
*
pbDagReader
{
fctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
curLinks
:=
getLinkCids
(
n
)
...
...
test/utils.go
View file @
e8ed89ce
...
...
@@ -27,6 +27,7 @@ func SizeSplitterGen(size int64) chunk.SplitterGen {
}
}
// GetDAGServ returns a mock DAGService.
func
GetDAGServ
()
node
.
DAGService
{
return
mdagmock
.
Mock
()
}
...
...
@@ -51,6 +52,7 @@ func init() {
UseBlake2b256
.
Prefix
.
MhLength
=
-
1
}
// GetNode returns a unixfs file node with the specified data.
func
GetNode
(
t
testing
.
TB
,
dserv
node
.
DAGService
,
data
[]
byte
,
opts
NodeOpts
)
node
.
Node
{
in
:=
bytes
.
NewReader
(
data
)
...
...
@@ -69,10 +71,12 @@ func GetNode(t testing.TB, dserv node.DAGService, data []byte, opts NodeOpts) no
return
node
}
// GetEmptyNode returns an empty unixfs file node.
func
GetEmptyNode
(
t
testing
.
TB
,
dserv
node
.
DAGService
,
opts
NodeOpts
)
node
.
Node
{
return
GetNode
(
t
,
dserv
,
[]
byte
{},
opts
)
}
// GetRandomNode returns a random unixfs file node.
func
GetRandomNode
(
t
testing
.
TB
,
dserv
node
.
DAGService
,
size
int64
,
opts
NodeOpts
)
([]
byte
,
node
.
Node
)
{
in
:=
io
.
LimitReader
(
u
.
NewTimeSeededRand
(),
size
)
buf
,
err
:=
ioutil
.
ReadAll
(
in
)
...
...
@@ -96,6 +100,7 @@ func ArrComp(a, b []byte) error {
return
nil
}
// PrintDag pretty-prints the given dag to stdout.
func
PrintDag
(
nd
*
mdag
.
ProtoNode
,
ds
node
.
DAGService
,
indent
int
)
{
pbd
,
err
:=
ft
.
FromBytes
(
nd
.
Data
())
if
err
!=
nil
{
...
...
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