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
db53de80
Commit
db53de80
authored
Nov 18, 2014
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/commands: Made 'refs' output u.Keys instead of strings
parent
477c246c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
core/commands/refs.go
core/commands/refs.go
+12
-9
No files found.
core/commands/refs.go
View file @
db53de80
...
...
@@ -2,7 +2,6 @@ package commands
import
(
"fmt"
"strings"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
cmds
"github.com/jbenet/go-ipfs/commands"
...
...
@@ -13,13 +12,16 @@ import (
// KeyList is a general type for outputting lists of keys
type
KeyList
struct
{
Keys
[]
string
Keys
[]
u
.
Key
}
// KeyListTextMarshaler outputs a KeyList as plaintext, one key per line
func
KeyListTextMarshaler
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
output
:=
res
.
Output
()
.
(
*
KeyList
)
s
:=
strings
.
Join
(
output
.
Keys
,
"
\n
"
)
s
:=
""
for
_
,
key
:=
range
output
.
Keys
{
s
+=
key
.
B58String
()
+
"
\n
"
}
return
[]
byte
(
s
),
nil
}
...
...
@@ -79,7 +81,7 @@ func getRefs(n *core.IpfsNode, paths []string, unique, recursive bool) (*KeyList
refsSeen
=
make
(
map
[
u
.
Key
]
bool
)
}
refs
:=
make
([]
string
,
0
)
refs
:=
make
([]
u
.
Key
,
0
)
for
_
,
path
:=
range
paths
{
object
,
err
:=
n
.
Resolver
.
ResolvePath
(
path
)
...
...
@@ -96,7 +98,7 @@ func getRefs(n *core.IpfsNode, paths []string, unique, recursive bool) (*KeyList
return
&
KeyList
{
refs
},
nil
}
func
addRefs
(
n
*
core
.
IpfsNode
,
object
*
dag
.
Node
,
refs
[]
string
,
refsSeen
map
[
u
.
Key
]
bool
,
recursive
bool
)
([]
string
,
error
)
{
func
addRefs
(
n
*
core
.
IpfsNode
,
object
*
dag
.
Node
,
refs
[]
u
.
Key
,
refsSeen
map
[
u
.
Key
]
bool
,
recursive
bool
)
([]
u
.
Key
,
error
)
{
for
_
,
link
:=
range
object
.
Links
{
var
found
bool
found
,
refs
=
addRef
(
link
.
Hash
,
refs
,
refsSeen
)
...
...
@@ -117,15 +119,16 @@ func addRefs(n *core.IpfsNode, object *dag.Node, refs []string, refsSeen map[u.K
return
refs
,
nil
}
func
addRef
(
h
mh
.
Multihash
,
refs
[]
string
,
refsSeen
map
[
u
.
Key
]
bool
)
(
bool
,
[]
string
)
{
func
addRef
(
h
mh
.
Multihash
,
refs
[]
u
.
Key
,
refsSeen
map
[
u
.
Key
]
bool
)
(
bool
,
[]
u
.
Key
)
{
key
:=
u
.
Key
(
h
)
if
refsSeen
!=
nil
{
_
,
found
:=
refsSeen
[
u
.
Key
(
h
)
]
_
,
found
:=
refsSeen
[
key
]
if
found
{
return
true
,
refs
}
refsSeen
[
u
.
Key
(
h
)
]
=
true
refsSeen
[
key
]
=
true
}
refs
=
append
(
refs
,
h
.
B58String
()
)
refs
=
append
(
refs
,
key
)
return
false
,
refs
}
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