mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-05 08:18:03 +08:00
Merge ef82852bde into 3d0e7c8465
This commit is contained in:
commit
f6f6831130
@ -458,7 +458,7 @@ var keyListCmd = &cmds.Command{
|
||||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
|
||||
keyEnc, err := ke.KeyEncoderFromString(req.Options[ke.OptionIPNSBase.Name()].(string))
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("cannot get key encoder: %w", err)
|
||||
}
|
||||
|
||||
api, err := cmdenv.GetApi(env, req)
|
||||
@ -468,7 +468,7 @@ var keyListCmd = &cmds.Command{
|
||||
|
||||
keys, err := api.Key().List(req.Context)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("listing keys failed: %w", err)
|
||||
}
|
||||
|
||||
list := make([]KeyOutput, 0, len(keys))
|
||||
|
||||
@ -29,7 +29,7 @@ type key struct {
|
||||
func newKey(name string, pid peer.ID) (*key, error) {
|
||||
p, err := path.NewPath("/ipns/" + ipns.NameFromPeer(pid).String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("cannot create new key: %w", err)
|
||||
}
|
||||
return &key{
|
||||
name: name,
|
||||
@ -121,34 +121,37 @@ func (api *KeyAPI) List(ctx context.Context) ([]coreiface.Key, error) {
|
||||
|
||||
keys, err := api.repo.Keystore().List()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("cannot list keys in keystore: %w", err)
|
||||
}
|
||||
|
||||
sort.Strings(keys)
|
||||
|
||||
out := make([]coreiface.Key, len(keys)+1)
|
||||
out := make([]coreiface.Key, 1, len(keys)+1)
|
||||
out[0], err = newKey("self", api.identity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for n, k := range keys {
|
||||
for _, k := range keys {
|
||||
privKey, err := api.repo.Keystore().Get(k)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Errorf("cannot get key from keystore: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
pubKey := privKey.GetPublic()
|
||||
|
||||
pid, err := peer.IDFromPublicKey(pubKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Errorf("cannot decode public key: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
out[n+1], err = newKey(k, pid)
|
||||
k, err := newKey(k, pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, k)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ This release was brought to you by the [Shipyard](https://ipshipyard.com/) team.
|
||||
- [🔦 Highlights](#-highlights)
|
||||
- [Routing V1 HTTP API now exposed by default](#routing-v1-http-api-now-exposed-by-default)
|
||||
- [Track total size when adding pins](#track-total-size-when-adding-pins)
|
||||
- [Skip bad keys when listing](#skip_bad_keys_when_listing)
|
||||
- [📦️ Dependency updates](#-dependency-updates)
|
||||
- [📝 Changelog](#-changelog)
|
||||
- [👨👩👧👦 Contributors](#-contributors)
|
||||
@ -33,6 +34,10 @@ Example output:
|
||||
Fetched/Processed 336 nodes (83 MB)
|
||||
```
|
||||
|
||||
#### Skip bad keys when listing
|
||||
|
||||
Change the `ipfs key list` behavior to log an error and continue listing keys when a key cannot be read from the keystore or decoded.
|
||||
|
||||
#### 📦️ Dependency updates
|
||||
|
||||
- update `go-libp2p` to [v0.46.0](https://github.com/libp2p/go-libp2p/releases/tag/v0.46.0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user