Commit cac6b37 1 parent 4de5eaa commit cac6b37 Copy full SHA for cac6b37
File tree 1 file changed +12
-9
lines changed
1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,18 @@ ipfs id supports the format option for output with the following keys:
62
62
return
63
63
}
64
64
65
- if len (req .Arguments ()) == 0 {
65
+ var id peer.ID
66
+ if len (req .Arguments ()) > 0 {
67
+ id = peer .ID (b58 .Decode (req .Arguments ()[0 ]))
68
+ if len (id ) == 0 {
69
+ res .SetError (cmds .ClientError ("Invalid peer id" ), cmds .ErrClient )
70
+ return
71
+ }
72
+ } else {
73
+ id = node .Identity
74
+ }
75
+
76
+ if id == node .Identity {
66
77
output , err := printSelf (node )
67
78
if err != nil {
68
79
res .SetError (err , cmds .ErrNormal )
@@ -72,14 +83,6 @@ ipfs id supports the format option for output with the following keys:
72
83
return
73
84
}
74
85
75
- pid := req .Arguments ()[0 ]
76
-
77
- id := peer .ID (b58 .Decode (pid ))
78
- if len (id ) == 0 {
79
- res .SetError (cmds .ClientError ("Invalid peer id" ), cmds .ErrClient )
80
- return
81
- }
82
-
83
86
// TODO handle offline mode with polymorphism instead of conditionals
84
87
if ! node .OnlineMode () {
85
88
res .SetError (errors .New (offlineIdErrorMessage ), cmds .ErrClient )
You can’t perform that action at this time.
0 commit comments