Skip to content

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
  • Loading branch information
vasco-santos and jacobheun committed May 13, 2020
1 parent 80e18c1 commit 171af8a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doc/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|------|------|-------------|
Expand Down
4 changes: 0 additions & 4 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

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

Expand All @@ -18,9 +17,6 @@ const DefaultConfig = {
maxDialsPerPeer: Constants.MAX_PER_PEER_DIALS,
dialTimeout: Constants.DIAL_TIMEOUT
},
keychain: {
datastore: new MemoryDatastore()
},
metrics: {
enabled: false
},
Expand Down
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/keychain/keychain.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ describe('libp2p.keychain', () => {
started: false,
config: {
keychain: {
datastore: new MemoryDatastore(),
pass: '12345678901234567890'
}
}
Expand Down

0 comments on commit 171af8a

Please sign in to comment.