Commit 7cebc3cc authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

inline prints

looking forward to fixing these again

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 24f0fa0f
...@@ -167,12 +167,7 @@ func initConfig(configFilename string, dspathOverride string, nBitsForKeypair in ...@@ -167,12 +167,7 @@ func initConfig(configFilename string, dspathOverride string, nBitsForKeypair in
return nil, err return nil, err
} }
identity, err := identityConfig(nBitsForKeypair, func() { identity, err := identityConfig(nBitsForKeypair)
fmt.Printf("generating key pair...")
}, func(ident config.Identity) {
fmt.Printf("done\n")
fmt.Printf("peer identity: %s\n", ident.PeerID)
})
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -222,21 +217,20 @@ func initConfig(configFilename string, dspathOverride string, nBitsForKeypair in ...@@ -222,21 +217,20 @@ func initConfig(configFilename string, dspathOverride string, nBitsForKeypair in
return conf, nil return conf, nil
} }
// identityConfig initializes a new identity. It calls onBegin when it begins // identityConfig initializes a new identity.
// to generate the identity and it calls onSuccess once the operation is func identityConfig(nbits int) (config.Identity, error) {
// completed successfully
func identityConfig(nbits int, onBegin func(), onSuccess func(config.Identity)) (config.Identity, error) {
// TODO guard higher up // TODO guard higher up
ident := config.Identity{} ident := config.Identity{}
if nbits < 1024 { if nbits < 1024 {
return ident, debugerror.New("Bitsize less than 1024 is considered unsafe.") return ident, debugerror.New("Bitsize less than 1024 is considered unsafe.")
} }
onBegin() fmt.Printf("generating key pair...")
sk, pk, err := ci.GenerateKeyPair(ci.RSA, nbits) sk, pk, err := ci.GenerateKeyPair(ci.RSA, nbits)
if err != nil { if err != nil {
return ident, err return ident, err
} }
fmt.Printf("done\n")
// currently storing key unencrypted. in the future we need to encrypt it. // currently storing key unencrypted. in the future we need to encrypt it.
// TODO(security) // TODO(security)
...@@ -251,7 +245,7 @@ func identityConfig(nbits int, onBegin func(), onSuccess func(config.Identity)) ...@@ -251,7 +245,7 @@ func identityConfig(nbits int, onBegin func(), onSuccess func(config.Identity))
return ident, err return ident, err
} }
ident.PeerID = id.Pretty() ident.PeerID = id.Pretty()
onSuccess(ident) fmt.Printf("peer identity: %s\n", ident.PeerID)
return ident, nil return ident, nil
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment