Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix OneShotHandler usage in floodsub.
  • Loading branch information
Roman S. Borschel committed May 30, 2020
commit 521fe2d6221abb8a59b08a0ac6d228490a7973bf
11 changes: 6 additions & 5 deletions protocols/floodsub/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use libp2p_swarm::{
NetworkBehaviourAction,
PollParameters,
ProtocolsHandler,
OneShotEvent,
OneShotHandler,
NotifyHandler,
DialPeerCondition,
Expand Down Expand Up @@ -237,7 +238,7 @@ impl Floodsub {
}

impl NetworkBehaviour for Floodsub {
type ProtocolsHandler = OneShotHandler<FloodsubProtocol, FloodsubRpc, InnerMessage>;
type ProtocolsHandler = OneShotHandler<FloodsubProtocol, FloodsubRpc, InnerMessage, ()>;
type OutEvent = FloodsubEvent;

fn new_handler(&mut self) -> Self::ProtocolsHandler {
Expand Down Expand Up @@ -287,12 +288,12 @@ impl NetworkBehaviour for Floodsub {
&mut self,
propagation_source: PeerId,
_connection: ConnectionId,
event: InnerMessage,
event: OneShotEvent<InnerMessage, ()>,
) {
// We ignore successful sends event.
// We ignore successful sends or timeouts.
let event = match event {
InnerMessage::Rx(event) => event,
InnerMessage::Sent => return,
OneShotEvent::Success(InnerMessage::Rx(event)) => event,
OneShotEvent::Success(InnerMessage::Sent) | OneShotEvent::Timeout(()) => return,
};

// Update connected peers topics
Expand Down