mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-24 18:12:14 +00:00
chore: apply suggestions from code review
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
parent
6065923356
commit
0be74e6a61
@ -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 |
|
||||
|------|------|-------------|
|
||||
|
@ -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
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -416,6 +416,7 @@ describe('libp2p.keychain', () => {
|
||||
started: false,
|
||||
config: {
|
||||
keychain: {
|
||||
datastore: new MemoryDatastore(),
|
||||
pass: '12345678901234567890'
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user