mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 03:28:25 +08:00
Document exported symbols
License: MIT Signed-off-by: Michael Muré <batolettre@gmail.com>
This commit is contained in:
@ -49,6 +49,7 @@ type KeyOutputList struct {
|
|||||||
Keys []KeyOutput
|
Keys []KeyOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KeyRenameOutput define the output type of keyRenameCmd
|
||||||
type KeyRenameOutput struct {
|
type KeyRenameOutput struct {
|
||||||
Was string
|
Was string
|
||||||
Now string
|
Now string
|
||||||
|
@ -11,10 +11,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Keystore interface {
|
type Keystore interface {
|
||||||
|
// Has return whether or not a key exist in the Keystore
|
||||||
Has(string) (bool, error)
|
Has(string) (bool, error)
|
||||||
|
// Put store a key in the Keystore
|
||||||
Put(string, ci.PrivKey) error
|
Put(string, ci.PrivKey) error
|
||||||
|
// Get retrieve a key from the Keystore
|
||||||
Get(string) (ci.PrivKey, error)
|
Get(string) (ci.PrivKey, error)
|
||||||
|
// Delete remove a key from the Keystore
|
||||||
Delete(string) error
|
Delete(string) error
|
||||||
|
// List return a list of key identifier
|
||||||
List() ([]string, error)
|
List() ([]string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +60,7 @@ func NewFSKeystore(dir string) (*FSKeystore, error) {
|
|||||||
return &FSKeystore{dir}, nil
|
return &FSKeystore{dir}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Has return whether or not a key exist in the Keystore
|
||||||
func (ks *FSKeystore) Has(name string) (bool, error) {
|
func (ks *FSKeystore) Has(name string) (bool, error) {
|
||||||
kp := filepath.Join(ks.dir, name)
|
kp := filepath.Join(ks.dir, name)
|
||||||
|
|
||||||
@ -71,6 +77,7 @@ func (ks *FSKeystore) Has(name string) (bool, error) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Put store a key in the Keystore
|
||||||
func (ks *FSKeystore) Put(name string, k ci.PrivKey) error {
|
func (ks *FSKeystore) Put(name string, k ci.PrivKey) error {
|
||||||
if err := validateName(name); err != nil {
|
if err := validateName(name); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -104,6 +111,7 @@ func (ks *FSKeystore) Put(name string, k ci.PrivKey) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get retrieve a key from the Keystore
|
||||||
func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) {
|
func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) {
|
||||||
if err := validateName(name); err != nil {
|
if err := validateName(name); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -122,6 +130,7 @@ func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) {
|
|||||||
return ci.UnmarshalPrivateKey(data)
|
return ci.UnmarshalPrivateKey(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete remove a key from the Keystore
|
||||||
func (ks *FSKeystore) Delete(name string) error {
|
func (ks *FSKeystore) Delete(name string) error {
|
||||||
if err := validateName(name); err != nil {
|
if err := validateName(name); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -132,6 +141,7 @@ func (ks *FSKeystore) Delete(name string) error {
|
|||||||
return os.Remove(kp)
|
return os.Remove(kp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List return a list of key identifier
|
||||||
func (ks *FSKeystore) List() ([]string, error) {
|
func (ks *FSKeystore) List() ([]string, error) {
|
||||||
dir, err := os.Open(ks.dir)
|
dir, err := os.Open(ks.dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -10,11 +10,13 @@ func NewMemKeystore() *MemKeystore {
|
|||||||
return &MemKeystore{make(map[string]ci.PrivKey)}
|
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) {
|
func (mk *MemKeystore) Has(name string) (bool, error) {
|
||||||
_, ok := mk.keys[name]
|
_, ok := mk.keys[name]
|
||||||
return ok, nil
|
return ok, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Put store a key in the Keystore
|
||||||
func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
|
func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
|
||||||
if err := validateName(name); err != nil {
|
if err := validateName(name); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -29,6 +31,7 @@ func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get retrieve a key from the Keystore
|
||||||
func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
|
func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
|
||||||
if err := validateName(name); err != nil {
|
if err := validateName(name); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -42,6 +45,7 @@ func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
|
|||||||
return k, nil
|
return k, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete remove a key from the Keystore
|
||||||
func (mk *MemKeystore) Delete(name string) error {
|
func (mk *MemKeystore) Delete(name string) error {
|
||||||
if err := validateName(name); err != nil {
|
if err := validateName(name); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -51,6 +55,7 @@ func (mk *MemKeystore) Delete(name string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List return a list of key identifier
|
||||||
func (mk *MemKeystore) List() ([]string, error) {
|
func (mk *MemKeystore) List() ([]string, error) {
|
||||||
out := make([]string, 0, len(mk.keys))
|
out := make([]string, 0, len(mk.keys))
|
||||||
for k, _ := range mk.keys {
|
for k, _ := range mk.keys {
|
||||||
|
Reference in New Issue
Block a user