Don't poll network unnecessarily. (#1977)

* Don't poll network unnecessarily.

* Fix ci.

* Damn tokio.

* Address review comments.

* Update deps.

* Don't drop packet if socket is not writable.

* Increase TTL and rename to `query_interval`.

* Update CHANGELOG.

Co-authored-by: Roman S. Borschel <roman@parity.io>
This commit is contained in:
David Craven
2021-03-02 10:18:24 +01:00
committed by GitHub
parent 6b5fa0324d
commit b727efee13
11 changed files with 651 additions and 950 deletions

View File

@@ -58,7 +58,7 @@ use libp2p::{
NetworkBehaviour,
identity,
floodsub::{self, Floodsub, FloodsubEvent},
mdns::{Mdns, MdnsEvent},
mdns::{Mdns, MdnsConfig, MdnsEvent},
swarm::NetworkBehaviourEventProcess
};
use std::{error::Error, task::{Context, Poll}};
@@ -121,7 +121,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// Create a Swarm to manage peers and events
let mut swarm = {
let mdns = task::block_on(Mdns::new())?;
let mdns = task::block_on(Mdns::new(MdnsConfig::default()))?;
let mut behaviour = MyBehaviour {
floodsub: Floodsub::new(local_peer_id.clone()),
mdns,