Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: allow pregenerated ids
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Aug 4, 2018
1 parent 99911b1 commit 3beef19
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/core/components/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,20 @@ module.exports = function init (self) {
return cb(new Error('repo already exists'))
}

// Generate peer identity keypair + transform to desired format + add to config.
opts.log(`generating ${opts.bits}-bit RSA keypair...`, false)
self.log('generating peer id: %s bits', opts.bits)
peerId.create({ bits: opts.bits }, cb)
if (opts.pregenId) {
// Use pregenerated Id
self.log('using pregenerated id')
cb(null, opts.pregenId)
} else if (process.env.IPFS_PREGENERATED_PRIVATE_KEY) {
// Use pregenerated Id from env
self.log('using pregenerated id from env')
peerId.createFromPrivKey(process.env.IPFS_PREGENERATED_PRIVATE_KEY, cb)
} else {
// Generate peer identity keypair + transform to desired format + add to config.
opts.log(`generating ${opts.bits}-bit RSA keypair...`, false)
self.log('generating peer id: %s bits', opts.bits)
peerId.create({ bits: opts.bits }, cb)
}
},
(keys, cb) => {
self.log('identity generated')
Expand Down

0 comments on commit 3beef19

Please sign in to comment.