Skip to content
Permalink
Browse files

Simplify handling of propagation messages

There is no need to return a future.
  • Loading branch information...
mzabaluev committed May 16, 2019
1 parent cc59cd0 commit 37d11fab5ebd81cb559f6aa25589b9ef3817da34
Showing with 6 additions and 9 deletions.
  1. +6 −9 src/network/mod.rs
@@ -195,7 +195,8 @@ fn handle_network_input(
) -> impl Future<Item = (), Error = ()> {
input.for_each(move |msg| match msg {
NetworkMsg::Propagate(msg) => {
future::Either::A(handle_propagation_msg(msg, state.clone(), channels.clone()))
handle_propagation_msg(msg, state.clone(), channels.clone());
future::Either::A(future::ok(()))
}
NetworkMsg::GetBlocks(node_id, block_ids) => {
let mut channels = channels.clone();
@@ -210,18 +211,14 @@ fn handle_network_input(
})
.or_else(move |e| {
warn!("failed to fetch blocks from peer {}: {:?}", node_id, e);
future::ok::<(), ()>(())
future::ok(())
}),
)
}
})
}

fn handle_propagation_msg(
msg: PropagateMsg,
state: GlobalStateR,
channels: Channels,
) -> impl Future<Item = (), Error = ()> {
fn handle_propagation_msg(msg: PropagateMsg, state: GlobalStateR, channels: Channels) {
debug!("to propagate: {:?}", &msg);
let nodes = state.topology.view().collect::<Vec<_>>();
debug!(
@@ -239,7 +236,7 @@ fn handle_propagation_msg(
// If any nodes selected for propagation are not in the
// active subscriptions map, connect to them and deliver
// the item.
future::result(res.map_err(|unreached_nodes| {
if let Err(unreached_nodes) = res {
for node in unreached_nodes {
let msg = msg.clone();
connect_and_propagate_with(
@@ -256,7 +253,7 @@ fn handle_propagation_msg(
},
);
}
}))
}
}

fn send_gossip(state: GlobalStateR, channels: Channels) {

0 comments on commit 37d11fa

Please sign in to comment.
You can’t perform that action at this time.