Commit c89e3c22 authored by Christian Couder's avatar Christian Couder

core/commands/pin: refactor 'pin ls'

License: MIT
Signed-off-by: default avatarChristian Couder <chriscool@tuxfamily.org>
parent b770c881
......@@ -212,13 +212,18 @@ Example:
}
keys := make(map[string]RefKeyObject)
if typeStr == "direct" || typeStr == "all" {
for _, k := range n.Pinning.DirectKeys() {
AddToResultKeys := func(keyList []key.Key, typeStr string) {
for _, k := range keyList {
keys[k.B58String()] = RefKeyObject{
Type: "direct",
Type: typeStr,
}
}
}
if typeStr == "direct" || typeStr == "all" {
AddToResultKeys(n.Pinning.DirectKeys(), "direct")
}
if typeStr == "indirect" || typeStr == "all" {
ks := key.NewKeySet()
for _, k := range n.Pinning.RecursiveKeys() {
......@@ -232,20 +237,11 @@ Example:
res.SetError(err, cmds.ErrNormal)
return
}
}
for _, k := range ks.Keys() {
keys[k.B58String()] = RefKeyObject{
Type: "indirect",
}
}
AddToResultKeys(ks.Keys(), "indirect")
}
if typeStr == "recursive" || typeStr == "all" {
for _, k := range n.Pinning.RecursiveKeys() {
keys[k.B58String()] = RefKeyObject{
Type: "recursive",
}
}
AddToResultKeys(n.Pinning.RecursiveKeys(), "recursive")
}
res.SetOutput(&RefKeyList{Keys: keys})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment