go-ipfs-config: interface
Will Scott committed
Apr 21, 2020 at 08:08 UTC
c6336c3303df300e88b592029390b0af6772afca
1 file changed
+7
-7
config/init.go
+7
-7
@@ -13,15 +13,15 @@ import (
13
)
14
15
func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
16
- return InitWithOptions(out, []options.KeyGenerateOption{options.Key.Size(nBitsForKeypair)})
17
-}
18
-
19
-func InitWithOptions(out io.Writer, opts []options.KeyGenerateOption) (*Config, error) {
20
- identity, err := identityConfig(out, opts)
16
+ identity, err := CreateIdentity(out, []options.KeyGenerateOption{options.Key.Size(nBitsForKeypair)})
17
if err != nil {
18
return nil, err
19
}
20
21
+ return InitWithIdentity(identity)
22
+}
23
+
24
+func InitWithIdentity(identity Identity) (*Config, error) {
25
bootstrapPeers, err := DefaultBootstrapPeers()
26
if err != nil {
27
return nil, err
@@ -170,8 +170,8 @@ func flatfsSpec() map[string]interface{} {
170
}
171
}
172
173
-// identityConfig initializes a new identity.
174
-func identityConfig(out io.Writer, opts []options.KeyGenerateOption) (Identity, error) {
173
+// CreateIdentity initializes a new identity.
174
+func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity, error) {
175
// TODO guard higher up
176
ident := Identity{}
177