Merge pull request #1171 from orbitdb/docs/blockstore-config

docs: Randomize blockstore location.
This commit is contained in:
Haad 2024-04-16 17:57:07 +03:00 committed by GitHub
commit 0550a44949
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,7 +27,7 @@ then instantiate and pass to Helia:
``` ```
import { LevelBlockstore } from 'blockstore-level' import { LevelBlockstore } from 'blockstore-level'
const blockstore = new LevelBlockstore('./ipfs') const blockstore = new LevelBlockstore('./ipfs/blocks')
const ipfs = createHelia({ blockstore }) const ipfs = createHelia({ blockstore })
``` ```
@ -117,7 +117,7 @@ import { LevelBlockstore } from 'blockstore-level'
import { Libp2pOptions } from './config/libp2p.js' import { Libp2pOptions } from './config/libp2p.js'
// Create an IPFS instance. // Create an IPFS instance.
const blockstore = new LevelBlockstore('./ipfs') const blockstore = new LevelBlockstore('./ipfs/blocks')
const libp2p = await createLibp2p(Libp2pOptions) const libp2p = await createLibp2p(Libp2pOptions)
const ipfs = await createHelia({ libp2p, blockstore }) const ipfs = await createHelia({ libp2p, blockstore })
@ -208,13 +208,13 @@ import { LevelBlockstore } from 'blockstore-level'
import { Libp2pOptions } from './config/libp2p.js' import { Libp2pOptions } from './config/libp2p.js'
const main = async () => { const main = async () => {
const blockstore = new LevelBlockstore('./ipfs')
const libp2p = await createLibp2p(Libp2pOptions)
const ipfs = await createHelia({ libp2p, blockstore })
// create a random directory to avoid OrbitDB conflicts. // create a random directory to avoid OrbitDB conflicts.
let randDir = (Math.random() + 1).toString(36).substring(2) let randDir = (Math.random() + 1).toString(36).substring(2)
const blockstore = new LevelBlockstore(`./${randDir}/ipfs/blocks`)
const libp2p = await createLibp2p(Libp2pOptions)
const ipfs = await createHelia({ libp2p, blockstore })
const orbitdb = await createOrbitDB({ ipfs, directory: `./${randDir}/orbitdb` }) const orbitdb = await createOrbitDB({ ipfs, directory: `./${randDir}/orbitdb` })
let db let db