@cryptotaxi247 / kubo / commits / 259349531

Document exported symbols

License: MIT Signed-off-by: Michael Muré <batolettre@gmail.com>

Michael Muré committed May 14, 2017 at 21:02 UTC 2593495311d57007fac382cb7a6667e8f1f6b58f
3 files changed +16
core/commands/keystore.go
+1
@@ -49,6 +49,7 @@ type KeyOutputList struct {
49 Keys []KeyOutput
50 }
51
52 +// KeyRenameOutput define the output type of keyRenameCmd
53 type KeyRenameOutput struct {
54 Was string
55 Now string
keystore/keystore.go
+10
@@ -11,10 +11,15 @@ import (
11 )
12
13 type Keystore interface {
14 + // Has return whether or not a key exist in the Keystore
15 Has(string) (bool, error)
16 + // Put store a key in the Keystore
17 Put(string, ci.PrivKey) error
18 + // Get retrieve a key from the Keystore
19 Get(string) (ci.PrivKey, error)
20 + // Delete remove a key from the Keystore
21 Delete(string) error
22 + // List return a list of key identifier
23 List() ([]string, error)
24 }
25
@@ -55,6 +60,7 @@ func NewFSKeystore(dir string) (*FSKeystore, error) {
60 return &FSKeystore{dir}, nil
61 }
62
63 +// Has return whether or not a key exist in the Keystore
64 func (ks *FSKeystore) Has(name string) (bool, error) {
65 kp := filepath.Join(ks.dir, name)
66
@@ -71,6 +77,7 @@ func (ks *FSKeystore) Has(name string) (bool, error) {
77 return true, nil
78 }
79
80 +// Put store a key in the Keystore
81 func (ks *FSKeystore) Put(name string, k ci.PrivKey) error {
82 if err := validateName(name); err != nil {
83 return err
@@ -104,6 +111,7 @@ func (ks *FSKeystore) Put(name string, k ci.PrivKey) error {
111 return nil
112 }
113
114 +// Get retrieve a key from the Keystore
115 func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) {
116 if err := validateName(name); err != nil {
117 return nil, err
@@ -122,6 +130,7 @@ func (ks *FSKeystore) Get(name string) (ci.PrivKey, error) {
130 return ci.UnmarshalPrivateKey(data)
131 }
132
133 +// Delete remove a key from the Keystore
134 func (ks *FSKeystore) Delete(name string) error {
135 if err := validateName(name); err != nil {
136 return err
@@ -132,6 +141,7 @@ func (ks *FSKeystore) Delete(name string) error {
141 return os.Remove(kp)
142 }
143
144 +// List return a list of key identifier
145 func (ks *FSKeystore) List() ([]string, error) {
146 dir, err := os.Open(ks.dir)
147 if err != nil {
keystore/memkeystore.go
+5
@@ -10,11 +10,13 @@ func NewMemKeystore() *MemKeystore {
10 return &MemKeystore{make(map[string]ci.PrivKey)}
11 }
12
13 +// Has return whether or not a key exist in the Keystore
14 func (mk *MemKeystore) Has(name string) (bool, error) {
15 _, ok := mk.keys[name]
16 return ok, nil
17 }
18
19 +// Put store a key in the Keystore
20 func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
21 if err := validateName(name); err != nil {
22 return err
@@ -29,6 +31,7 @@ func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
31 return nil
32 }
33
34 +// Get retrieve a key from the Keystore
35 func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
36 if err := validateName(name); err != nil {
37 return nil, err
@@ -42,6 +45,7 @@ func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
45 return k, nil
46 }
47
48 +// Delete remove a key from the Keystore
49 func (mk *MemKeystore) Delete(name string) error {
50 if err := validateName(name); err != nil {
51 return err
@@ -51,6 +55,7 @@ func (mk *MemKeystore) Delete(name string) error {
55 return nil
56 }
57
58 +// List return a list of key identifier
59 func (mk *MemKeystore) List() ([]string, error) {
60 out := make([]string, 0, len(mk.keys))
61 for k, _ := range mk.keys {