inline prints
looking forward to fixing these again License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Nov 17, 2014 at 21:15 UTC
7cebc3cc38e3c864067b0144dd4cb22773ef7590
1 file changed
+6
-12
cmd/ipfs2/init.go
+6
-12
@@ -167,12 +167,7 @@ func initConfig(configFilename string, dspathOverride string, nBitsForKeypair in
167
return nil, err
168
}
169
170
- identity, err := identityConfig(nBitsForKeypair, func() {
171
- fmt.Printf("generating key pair...")
172
- }, func(ident config.Identity) {
173
- fmt.Printf("done\n")
174
- fmt.Printf("peer identity: %s\n", ident.PeerID)
175
- })
170
+ identity, err := identityConfig(nBitsForKeypair)
171
if err != nil {
172
return nil, err
173
}
@@ -222,21 +217,20 @@ func initConfig(configFilename string, dspathOverride string, nBitsForKeypair in
217
return conf, nil
218
}
219
225
-// identityConfig initializes a new identity. It calls onBegin when it begins
226
-// to generate the identity and it calls onSuccess once the operation is
227
-// completed successfully
228
-func identityConfig(nbits int, onBegin func(), onSuccess func(config.Identity)) (config.Identity, error) {
220
+// identityConfig initializes a new identity.
221
+func identityConfig(nbits int) (config.Identity, error) {
222
// TODO guard higher up
223
ident := config.Identity{}
224
if nbits < 1024 {
225
return ident, debugerror.New("Bitsize less than 1024 is considered unsafe.")
226
}
227
235
- onBegin()
228
+ fmt.Printf("generating key pair...")
229
sk, pk, err := ci.GenerateKeyPair(ci.RSA, nbits)
230
if err != nil {
231
return ident, err
232
}
233
+ fmt.Printf("done\n")
234
235
// currently storing key unencrypted. in the future we need to encrypt it.
236
// TODO(security)
@@ -251,7 +245,7 @@ func identityConfig(nbits int, onBegin func(), onSuccess func(config.Identity))
245
return ident, err
246
}
247
ident.PeerID = id.Pretty()
254
- onSuccess(ident)
248
+ fmt.Printf("peer identity: %s\n", ident.PeerID)
249
return ident, nil
250
}
251