Added logging for ignored keyfiles in keystore.List and minor improvements.
License: MIT Signed-off-by: matrushka <barisgumustas@gmail.com>
matrushka committed
Feb 14, 2018 at 18:16 UTC
40aeea6abd54ddf9a58238d62e70162fb73164f8
1 file changed
+7
-2
keystore/keystore.go
+7
-2
@@ -7,9 +7,12 @@ import (
7
"path/filepath"
8
"strings"
9
10
+ logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
11
ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto"
12
)
13
14
+var log = logging.Logger("keystore")
15
+
16
// Keystore provides a key management interface
17
type Keystore interface {
18
// Has returns whether or not a key exist in the Keystore
@@ -158,14 +161,16 @@ func (ks *FSKeystore) List() ([]string, error) {
161
return nil, err
162
}
163
161
- var list []string
164
+ list := make([]string, 0)
165
166
for _, name := range dirs {
167
err := validateName(name)
168
if err == nil {
169
list = append(list, name)
170
+ } else {
171
+ log.Warningf("Ignoring the invalid keyfile: %s", name)
172
}
173
}
174
170
- return list, err
175
+ return list, nil
176
}