orbitdb / orbitdb

Peer-to-Peer Databases for the Decentralized Web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When put data, tell me 'PublishError.NoPeersSubscribedToTopic' error. How can i fix this? THX

uninstalls opened this issue · comments

const libp2p = await createLibp2p({
        services: {
        pubsub: gossipsub({
          allowPublishToZeroPeers: true
        }),
        identify: identify()
      }
    })

const block = new LevelBlockstore('./ipfs')

const ipfs = await createHelia({libp2p, block})
// console.log(ipfs)
const orbitdb = await createOrbitDB({ipfs})
// console.log(orbitdb)

const db = await orbitdb.open('testdb', {type: 'keyvalue'})
console.log(db.address)

const hash = await db.put('test', 'hello world')
console.log(hash)`

This is my code

Hi, this seems to be a libp2p question! Which libp2p version do you have?

In case you have 1.3.0 (as I have) you the attribute is called
allowPublishToZeroTopicPeers: true
instead of:
allowPublishToZeroPeers: true

now.

That's my Libp2pOption.
You should add emitSelf: true on there.

const Libp2pOptions = {
  peerDiscovery: [mdns()],
  addresses: {
    listen: ['/ip4/0.0.0.0/tcp/0'],
  },
  transports: [tcp()],
  connectionEncryption: [noise()],
  streamMuxers: [yamux()],
  services: {
    identify: identify(),
    pubsub: gossipsub({ allowPublishToZeroPeers: true, emitSelf: true }),
  },
};```

Closing as appears answered. Feel free to re-open if the problem persists.