How to create a "private" P2P network via Rust libp2p

So I’m trying to develop a p2p network, using Gossipsub protocol and Kademlia. My main objective is to divide peers per network ID, so that if a peer is from a network it can’t see peers from another network.

The problem is that i can’t find any place where to define a network ID in the Rust lib, not in the documentation nor in the exaples.

Any help, advice, examples to follows or documentation?
Thanks in advance! :slight_smile:

Hi @vnmRD,

You can set the protocol name here:

https://github.com/libp2p/rust-libp2p/blob/65cc8994a6230b43e74b53b42b5c5c8655320d5e/protocols/kad/src/behaviour.rs#L218-L226

Let me know if this helps.

1 Like

It was exactly what i was looking for

because we are already here, in kad which is the confgi setting to express how many peers i want as neighbours?

Depends on what you define as “neighbours”, the K-Value? If so, that is constant today:

1 Like