1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 18:13:54 +08:00

Document exported symbols

License: MIT
Signed-off-by: Michael Muré <batolettre@gmail.com>
This commit is contained in:
Michael Muré
2017-05-14 21:02:01 +09:00
parent cb8d5eb245
commit 2593495311
3 changed files with 16 additions and 0 deletions

View File

@ -49,6 +49,7 @@ type KeyOutputList struct {
Keys []KeyOutput
}
// KeyRenameOutput define the output type of keyRenameCmd
type KeyRenameOutput struct {
Was string
Now string

View File

@ -11,10 +11,15 @@ import (
)
type Keystore interface {
// Has return whether or not a key exist in the Keystore
Has(string) (bool, error)
// Put store a key in the Keystore
Put(string, ci.PrivKey) error
// Get retrieve a key from the Keystore
Get(string) (ci.PrivKey, error)
// Delete remove a key from the Keystore
Delete(string) error
// List return a list of key identifier
List() ([]string, error)
}
@ -55,6 +60,7 @@ func NewFSKeystore(dir string) (*FSKeystore, error) {
return &FSKeystore{dir}, nil
}
// Has return whether or not a key exist in the Keystore
func (ks *FSKeystore) Has(name string) (bool, error) {
kp := filepath.Join(ks.dir, name)
@ -71,6 +77,7 @@ func (ks *FSKeystore) Has(name string) (bool, error) {
return true, nil
}
// Put store a key in the Keystore
func (ks *FSKeystore) Put(name string, k ci.PrivKey) error {
if err := validateName(name); err != nil {
return err
@ -104,6 +111,7 @@ func (ks *FSKeystore) Put(name string, k ci.PrivKey) error {
return nil
}
// Get retrieve a key from the Keystore
func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) {
if err := validateName(name); err != nil {
return nil, err
@ -122,6 +130,7 @@ func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) {
return ci.UnmarshalPrivateKey(data)
}
// Delete remove a key from the Keystore
func (ks *FSKeystore) Delete(name string) error {
if err := validateName(name); err != nil {
return err
@ -132,6 +141,7 @@ func (ks *FSKeystore) Delete(name string) error {
return os.Remove(kp)
}
// List return a list of key identifier
func (ks *FSKeystore) List() ([]string, error) {
dir, err := os.Open(ks.dir)
if err != nil {

View File

@ -10,11 +10,13 @@ func NewMemKeystore() *MemKeystore {
return &MemKeystore{make(map[string]ci.PrivKey)}
}
// Has return whether or not a key exist in the Keystore
func (mk *MemKeystore) Has(name string) (bool, error) {
_, ok := mk.keys[name]
return ok, nil
}
// Put store a key in the Keystore
func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
if err := validateName(name); err != nil {
return err
@ -29,6 +31,7 @@ func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
return nil
}
// Get retrieve a key from the Keystore
func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
if err := validateName(name); err != nil {
return nil, err
@ -42,6 +45,7 @@ func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
return k, nil
}
// Delete remove a key from the Keystore
func (mk *MemKeystore) Delete(name string) error {
if err := validateName(name); err != nil {
return err
@ -51,6 +55,7 @@ func (mk *MemKeystore) Delete(name string) error {
return nil
}
// List return a list of key identifier
func (mk *MemKeystore) List() ([]string, error) {
out := make([]string, 0, len(mk.keys))
for k, _ := range mk.keys {