-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add keysize through an option to spawn #203
Changes from 1 commit
2595fc4
718e0ce
c9c25da
c3fca62
55142c5
17d578e
f5f400e
ee74427
b167a3c
ac70cda
6c7a028
2ca9aa1
1351dde
fb30e0e
174e9dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,8 +74,8 @@ class FactoryDaemon { | |
* Spawn an IPFS node, either js-ipfs or go-ipfs | ||
* | ||
* Options are: | ||
* - `init` {bool|Object} - should the node be initialized | ||
* - if `init` is an Object, it is expected to be of the form `{keySize: <bits>}` | ||
* - `init` bool - should the node be initialized | ||
* - `initOpts` Object, it is expected to be of the form `{bits: <size>}`, which sets the desired key size | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the README as well |
||
* - `start` bool - should the node be started | ||
* - `repoPath` string - the repository path to use for this node, ignored if node is disposable | ||
* - `disposable` bool - a new repo is created and initialized for each invocation | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,14 +57,9 @@ class Daemon { | |
this._gatewayAddr = null | ||
this._started = false | ||
this.api = null | ||
this.keySize = null | ||
this.bits = null | ||
|
||
this.keySize = process.env.IPFS_KEYSIZE | ||
|
||
// option takes precedence over env variable | ||
if (typeof this.opts.init === 'object') { | ||
this.keySize = this.opts.init.keySize | ||
} | ||
this.bits = this.opts.initOpts ? this.opts.initOpts.bits : process.env.IPFS_KEYSIZE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L60 is redundant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
if (this.opts.env) { | ||
Object.assign(this.env, this.opts.env) | ||
|
@@ -120,7 +115,7 @@ class Daemon { | |
* Initialize a repo. | ||
* | ||
* @param {Object} [initOpts={}] | ||
* @param {number} [initOpts.keysize=2048] - The bit size of the identiy key. | ||
* @param {number} [initOpts.bits=2048] - The bit size of the identiy key. | ||
* @param {string} [initOpts.directory=IPFS_PATH] - The location of the repo. | ||
* @param {string} [initOpts.pass] - The passphrase of the keychain. | ||
* @param {function (Error, Node)} callback | ||
|
@@ -136,19 +131,19 @@ class Daemon { | |
this.path = initOpts.directory | ||
} | ||
|
||
const keySize = initOpts.keysize ? initOpts.keysize : this.keySize | ||
const bits = initOpts.bits ? initOpts.bits : this.bits | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this repeating part of line 61? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const args = ['init'] | ||
// do not just set a default keysize, | ||
// in case we decide to change it at | ||
// the daemon level in the future | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sentence doesn't read right. Do you mean "Skip if default daemon keysize"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, ipfs daemons have a default keysize when using |
||
if (keySize) { | ||
args.concat(['-b', keySize]) | ||
if (bits) { | ||
args.concat(['-b', bits]) | ||
} | ||
if (initOpts.pass) { | ||
args.push('--pass') | ||
args.push('"' + initOpts.pass + '"') | ||
} | ||
log(`initializing with keysize: ${keySize}`) | ||
log(`initializing with keysize: ${bits}`) | ||
run(this, args, { env: this.env }, (err, result) => { | ||
if (err) { | ||
return callback(err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dryajov please set these values on tests themselves.