coreapi key: error on self if ident not loaded
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Oct 4, 2018 at 22:10 UTC
7807f575f1e40688a200ce1925fe3cdc6076c67a
1 file changed
+5
core/coreapi/key.go
+5
@@ -3,6 +3,7 @@ package coreapi
3
import (
4
"context"
5
"crypto/rand"
6
+ "errors"
7
"fmt"
8
"sort"
9
@@ -218,5 +219,9 @@ func (api *KeyAPI) Remove(ctx context.Context, name string) (coreiface.Key, erro
219
}
220
221
func (api *KeyAPI) Self(ctx context.Context) (coreiface.Key, error) {
222
+ if api.node.Identity == "" {
223
+ return nil, errors.New("identity not loaded")
224
+ }
225
+
226
return &key{"self", api.node.Identity}, nil
227
}