chore: apply suggestions from code review

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
Vasco Santos 2020-05-13 13:18:07 +02:00 committed by Jacob Heun
parent 6065923356
commit 0be74e6a61
4 changed files with 4 additions and 8 deletions

View File

@ -425,7 +425,7 @@ const node = await Libp2p.create({
#### Setup with Keychain
Libp2p allows you to setup a secure key chain to manage your keys. The keychain configuration object should have the following properties:
Libp2p allows you to setup a secure keychain to manage your keys. The keychain configuration object should have the following properties:
| Name | Type | Description |
|------|------|-------------|

View File

@ -1,6 +1,5 @@
'use strict'
const { MemoryDatastore } = require('interface-datastore')
const mergeOptions = require('merge-options')
const Constants = require('./constants')
@ -18,9 +17,6 @@ const DefaultConfig = {
maxDialsPerPeer: Constants.MAX_PER_PEER_DIALS,
dialTimeout: Constants.DIAL_TIMEOUT
},
keychain: {
datastore: new MemoryDatastore()
},
metrics: {
enabled: false
},

View File

@ -76,13 +76,12 @@ class Libp2p extends EventEmitter {
}
// Create keychain
if (this._options.keychain.pass) {
if (this._options.keychain && this._options.keychain.pass && this._options.keychain.datastore) {
log('creating keychain')
const datastore = this._options.keychain.datastore
const keychainOpts = Keychain.generateOptions()
this.keychain = new Keychain(datastore, {
this.keychain = new Keychain(this._options.keychain.datastore, {
passPhrase: this._options.keychain.pass,
...keychainOpts,
...this._options.keychain

View File

@ -416,6 +416,7 @@ describe('libp2p.keychain', () => {
started: false,
config: {
keychain: {
datastore: new MemoryDatastore(),
pass: '12345678901234567890'
}
}