mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-31 00:12:00 +00:00
fix: use placeholder dht/pubsub (#1193)
Instead of making the `.dht` and `.pubsub` properties optional, use dummy implementations that throw exceptions if they are not configured. This way we don't have to null guard everywhere they are accessed.
This commit is contained in:
@@ -4,7 +4,7 @@ import { createLibp2p } from 'libp2p'
|
||||
import { TCP } from '@libp2p/tcp'
|
||||
import { Mplex } from '@libp2p/mplex'
|
||||
import { Noise } from '@chainsafe/libp2p-noise'
|
||||
import { Gossipsub } from '@achingbrain/libp2p-gossipsub'
|
||||
import { FloodSub } from '@libp2p/floodsub'
|
||||
import { Bootstrap } from '@libp2p/bootstrap'
|
||||
import { PubSubPeerDiscovery } from '@libp2p/pubsub-peer-discovery'
|
||||
|
||||
@@ -16,7 +16,7 @@ const createNode = async (bootstrappers) => {
|
||||
transports: [new TCP()],
|
||||
streamMuxers: [new Mplex()],
|
||||
connectionEncryption: [new Noise()],
|
||||
pubsub: new Gossipsub(),
|
||||
pubsub: new FloodSub(),
|
||||
peerDiscovery: [
|
||||
new Bootstrap({
|
||||
list: bootstrappers
|
||||
@@ -40,7 +40,7 @@ const createNode = async (bootstrappers) => {
|
||||
transports: [new TCP()],
|
||||
streamMuxers: [new Mplex()],
|
||||
connectionEncryption: [new Noise()],
|
||||
pubsub: new Gossipsub(),
|
||||
pubsub: new FloodSub(),
|
||||
peerDiscovery: [
|
||||
new PubSubPeerDiscovery({
|
||||
interval: 1000
|
||||
|
Reference in New Issue
Block a user