mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 02:22:14 +00:00
chore: update datastore usage in CONFIGURATION.md (#982)
Co-authored-by: Vasco Santos <vasco.santos@ua.pt>
This commit is contained in:
parent
d3f78edffe
commit
97107c4ef7
@ -1,4 +1,4 @@
|
|||||||
# Configuration
|
#
|
||||||
|
|
||||||
- [Configuration](#configuration)
|
- [Configuration](#configuration)
|
||||||
- [Overview](#overview)
|
- [Overview](#overview)
|
||||||
@ -503,6 +503,9 @@ const MPLEX = require('libp2p-mplex')
|
|||||||
const { NOISE } = require('libp2p-noise')
|
const { NOISE } = require('libp2p-noise')
|
||||||
const LevelStore = require('datastore-level')
|
const LevelStore = require('datastore-level')
|
||||||
|
|
||||||
|
const datastore = new LevelStore('path/to/store')
|
||||||
|
await datastore.open()
|
||||||
|
|
||||||
const node = await Libp2p.create({
|
const node = await Libp2p.create({
|
||||||
modules: {
|
modules: {
|
||||||
transport: [TCP],
|
transport: [TCP],
|
||||||
@ -511,7 +514,7 @@ const node = await Libp2p.create({
|
|||||||
},
|
},
|
||||||
keychain: {
|
keychain: {
|
||||||
pass: 'notsafepassword123456789',
|
pass: 'notsafepassword123456789',
|
||||||
datastore: new LevelStore('path/to/store')
|
datastore: dsInstant,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -673,16 +676,18 @@ const Libp2p = require('libp2p')
|
|||||||
const TCP = require('libp2p-tcp')
|
const TCP = require('libp2p-tcp')
|
||||||
const MPLEX = require('libp2p-mplex')
|
const MPLEX = require('libp2p-mplex')
|
||||||
const { NOISE } = require('libp2p-noise')
|
const { NOISE } = require('libp2p-noise')
|
||||||
|
|
||||||
const LevelStore = require('datastore-level')
|
const LevelStore = require('datastore-level')
|
||||||
|
|
||||||
|
const datastore = new LevelStore('path/to/store')
|
||||||
|
const dsInstant = await datastore.open()
|
||||||
|
|
||||||
const node = await Libp2p.create({
|
const node = await Libp2p.create({
|
||||||
modules: {
|
modules: {
|
||||||
transport: [TCP],
|
transport: [TCP],
|
||||||
streamMuxer: [MPLEX],
|
streamMuxer: [MPLEX],
|
||||||
connEncryption: [NOISE]
|
connEncryption: [NOISE]
|
||||||
},
|
},
|
||||||
datastore: new LevelStore('path/to/store'),
|
datastore: dsInstant,
|
||||||
peerStore: {
|
peerStore: {
|
||||||
persistence: true,
|
persistence: true,
|
||||||
threshold: 5
|
threshold: 5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user