提交 7807f575 作者: Łukasz Magiera

coreapi key: error on self if ident not loaded

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 181c3999
...@@ -3,6 +3,7 @@ package coreapi ...@@ -3,6 +3,7 @@ package coreapi
import ( import (
"context" "context"
"crypto/rand" "crypto/rand"
"errors"
"fmt" "fmt"
"sort" "sort"
...@@ -218,5 +219,9 @@ func (api *KeyAPI) Remove(ctx context.Context, name string) (coreiface.Key, erro ...@@ -218,5 +219,9 @@ func (api *KeyAPI) Remove(ctx context.Context, name string) (coreiface.Key, erro
} }
func (api *KeyAPI) Self(ctx context.Context) (coreiface.Key, error) { func (api *KeyAPI) Self(ctx context.Context) (coreiface.Key, error) {
if api.node.Identity == "" {
return nil, errors.New("identity not loaded")
}
return &key{"self", api.node.Identity}, nil return &key{"self", api.node.Identity}, nil
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论