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
68693783
Commit
68693783
authored
10 years ago
by
Matt Bell
Committed by
Juan Batiz-Benet
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/commands2: Made 'resolve' output match old command
parent
2d756473
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
33 deletions
+17
-33
core/commands2/resolve.go
core/commands2/resolve.go
+17
-33
No files found.
core/commands2/resolve.go
View file @
68693783
...
...
@@ -4,13 +4,8 @@ import (
"errors"
cmds
"github.com/jbenet/go-ipfs/commands"
core
"github.com/jbenet/go-ipfs/core"
)
type
ResolveOutput
struct
{
Entries
[]
IpnsEntry
}
var
resolveCmd
=
&
cmds
.
Command
{
Description
:
"Gets the value currently published at an IPNS name"
,
Help
:
`IPNS is a PKI namespace, where names are the hashes of public keys, and
...
...
@@ -33,13 +28,13 @@ Resolve te value of another name:
`
,
Arguments
:
[]
cmds
.
Argument
{
cmds
.
Argument
{
"name"
,
cmds
.
ArgString
,
false
,
tru
e
,
cmds
.
Argument
{
"name"
,
cmds
.
ArgString
,
false
,
fals
e
,
"The IPNS name to resolve. Defaults to your node's peerID."
},
},
Run
:
func
(
res
cmds
.
Response
,
req
cmds
.
Request
)
{
n
:=
req
.
Context
()
.
Node
var
name
s
[]
string
var
name
string
if
n
.
Network
==
nil
{
res
.
SetError
(
errNotOnline
,
cmds
.
ErrNormal
)
...
...
@@ -51,40 +46,29 @@ Resolve te value of another name:
res
.
SetError
(
errors
.
New
(
"Identity not loaded!"
),
cmds
.
ErrNormal
)
return
}
names
=
append
(
names
,
n
.
Identity
.
ID
()
.
String
())
name
=
n
.
Identity
.
ID
()
.
String
()
}
else
{
for
_
,
arg
:=
range
req
.
Arguments
()
{
name
,
ok
:=
arg
.
(
string
)
if
!
ok
{
res
.
SetError
(
errors
.
New
(
"cast error"
),
cmds
.
ErrNormal
)
return
}
names
=
append
(
names
,
name
)
var
ok
bool
name
,
ok
=
req
.
Arguments
()[
0
]
.
(
string
)
if
!
ok
{
res
.
SetError
(
errors
.
New
(
"cast error"
),
cmds
.
ErrNormal
)
return
}
}
entries
,
err
:=
r
esolve
(
n
,
name
s
)
output
,
err
:=
n
.
Namesys
.
R
esolve
(
name
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
res
.
SetOutput
(
&
ResolveOutput
{
entries
})
res
.
SetOutput
(
output
)
},
Marshallers
:
map
[
cmds
.
EncodingType
]
cmds
.
Marshaller
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
output
:=
res
.
Output
()
.
(
string
)
return
[]
byte
(
output
),
nil
},
},
Type
:
&
ResolveOutput
{},
}
func
resolve
(
n
*
core
.
IpfsNode
,
names
[]
string
)
([]
IpnsEntry
,
error
)
{
var
entries
[]
IpnsEntry
for
_
,
name
:=
range
names
{
resolved
,
err
:=
n
.
Namesys
.
Resolve
(
name
)
if
err
!=
nil
{
return
nil
,
err
}
entries
=
append
(
entries
,
IpnsEntry
{
Name
:
name
,
Value
:
resolved
,
})
}
return
entries
,
nil
}
This diff is collapsed.
Click to expand it.
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