Skip to content

Commit 0be74e6

Browse files
vasco-santosjacobheun
andcommittedMay 28, 2020
chore: apply suggestions from code review
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
1 parent 6065923 commit 0be74e6

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed
 

‎doc/CONFIGURATION.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ const node = await Libp2p.create({
425425

426426
#### Setup with Keychain
427427

428-
Libp2p allows you to setup a secure key chain to manage your keys. The keychain configuration object should have the following properties:
428+
Libp2p allows you to setup a secure keychain to manage your keys. The keychain configuration object should have the following properties:
429429

430430
| Name | Type | Description |
431431
|------|------|-------------|

‎src/config.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict'
22

3-
const { MemoryDatastore } = require('interface-datastore')
43
const mergeOptions = require('merge-options')
54
const Constants = require('./constants')
65

@@ -18,9 +17,6 @@ const DefaultConfig = {
1817
maxDialsPerPeer: Constants.MAX_PER_PEER_DIALS,
1918
dialTimeout: Constants.DIAL_TIMEOUT
2019
},
21-
keychain: {
22-
datastore: new MemoryDatastore()
23-
},
2420
metrics: {
2521
enabled: false
2622
},

‎src/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,12 @@ class Libp2p extends EventEmitter {
7676
}
7777

7878
// Create keychain
79-
if (this._options.keychain.pass) {
79+
if (this._options.keychain && this._options.keychain.pass && this._options.keychain.datastore) {
8080
log('creating keychain')
8181

82-
const datastore = this._options.keychain.datastore
8382
const keychainOpts = Keychain.generateOptions()
8483

85-
this.keychain = new Keychain(datastore, {
84+
this.keychain = new Keychain(this._options.keychain.datastore, {
8685
passPhrase: this._options.keychain.pass,
8786
...keychainOpts,
8887
...this._options.keychain

‎test/keychain/keychain.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ describe('libp2p.keychain', () => {
416416
started: false,
417417
config: {
418418
keychain: {
419+
datastore: new MemoryDatastore(),
419420
pass: '12345678901234567890'
420421
}
421422
}

0 commit comments

Comments
 (0)
Please sign in to comment.