coreapi key: error on self if ident not loaded

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
Łukasz Magiera 2018-10-04 22:10:09 +02:00
parent 181c39993a
commit 7807f575f1

View File

@ -3,6 +3,7 @@ package coreapi
import (
"context"
"crypto/rand"
"errors"
"fmt"
"sort"
@ -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) {
if api.node.Identity == "" {
return nil, errors.New("identity not loaded")
}
return &key{"self", api.node.Identity}, nil
}