libp2p / rust-libp2p

The Rust Implementation of the libp2p networking stack.
https://libp2p.io
MIT License
4.46k stars 928 forks source link

Confusing/unclear comment on creating a KadConnecConfig #363

Closed jamesray1 closed 5 years ago

jamesray1 commented 6 years ago

Not sure if this is a good way to create a KadConnecConfig, but otherwise I don't know of a better way, if any. https://github.com/jamesray1/rust-libp2p/blob/a0601a0b0893bacc279e0d59b147cb07918c0ebb/gossipsub/src/lib.rs#L110. PS I tried IRC a couple of times but nobody was online, and it seems that unlike Gitter two people need to be online at the same time to have a convo. Creating a gitter room for gossipsub would probably be more appropriate.

Context:

tomaka commented 6 years ago

PS I tried IRC a couple of times but nobody was online, and it seems that unlike Gitter two people need to be online at the same time to have a convo.

People usually leave an IRC client open at all time. I'm in #libp2p on freenode with a lot of people related to libp2p development.

jamesray1 commented 6 years ago

I don't know if it's because of the time difference, but no one is on that channel right now. Leaving the computer on all the time is not energy efficient.

jamesray1 commented 6 years ago

It's taking me a long time to get my head around how to implement this.

At the moment what I have implemented includes:

        let transport = TcpConfig::new()
            .with_upgrade({
                let upgrade = SecioConfig {
                    // See the documentation of `SecioKeyPair`.
                    key: ed25519_generated().unwrap(),
                }.unwrap();

                upgrade::map(upgrade, |out: SecioOutput<_>| out.stream).unwrap()
            });
        let kad_connec_config = KadConnecConfig::new();
        let kad_connec_config_transport = kad_connec_config
             .upgrade(transport, (), Dialer, Future::"/ip4/0.0.0.0/tcp/0".parse().expect("invalid multiaddr"));

Edit: it seems like "/ip4/0.0.0.0/tcp/0" is OK. (I wasn't sure before).

See https://github.com/libp2p/rust-libp2p/blob/49ff4ce3087a0e7030eea20a28a2e809babe3702/gossipsub/src/membership_management/join.rs for more details.

Thanks for https://github.com/libp2p/rust-libp2p/tree/master/libp2p/examples!

tomaka commented 6 years ago

Sorry if the documentation and examples are not the greatest at the moment. I'm a bit confused, if your objective is to implement gossip then I don't think you need to interface with Kademlia at all.

jamesray1 commented 6 years ago

For gossipsub and episub a DHT can be used for peer routing, i.e. 'the ability to look up addresses for peers'.

tomaka commented 5 years ago

Considering that the library has seen tremendous change since then, I'm going to close this issue!