From af0048991c33ee76fd5423f944f1a3a28cb0c2e1 Mon Sep 17 00:00:00 2001 From: Karsten Ohme Date: Thu, 1 Feb 2024 22:45:21 +0100 Subject: [PATCH] Error: PublishError.InsufficientPeers (#1149) * Error: PublishError.InsufficientPeers Prevent Error: PublishError.InsufficientPeers when starting alone * Update README.md added whitespace * Update README.md spacing corrected --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b7e3cd7..888e9cb 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,23 @@ If you're using `@orbitdb/core` to develop **browser** or **Node.js** applicatio ```javascript import { createHelia } from 'helia' import { createOrbitDB } from '@orbitdb/core' +import { gossipsub } from "@chainsafe/libp2p-gossipsub"; +import { identify } from "@libp2p/identify"; +import { createLibp2p } from 'libp2p' + +const Libp2pOptions = { + services: { + pubsub: gossipsub({ + // neccessary to run a single peer + allowPublishToZeroPeers: true + }), + identify: identify() + } +} ;(async function () { - const ipfs = await createHelia() + const libp2p = await createLibp2p({ ...Libp2pOptions }) + const ipfs = await createHelia({libp2p}) const orbitdb = await createOrbitDB({ ipfs }) // Create / Open a database. Defaults to db type "events". @@ -78,6 +92,7 @@ import { createOrbitDB } from '@orbitdb/core' await orbitdb.stop() await ipfs.stop() })() + ``` To configure your [IPFS instance](https://github.com/ipfs/helia) for persistency and [Libp2p](https://github.com/libp2p/js-libp2p) to connect to peers, see [Creating a Helia instance](https://github.com/orbitdb/quickstart/blob/main/src/index.js) and the [Default Libp2p Configurations](https://github.com/orbitdb/quickstart/blob/main/src/config/libp2p/index.js) in [@orbitdb/quickstart](https://github.com/orbitdb/quickstart/blob/main/src/config/libp2p/index.js) for examples.