Fix potential state mismatch in behaviour.rs (#6013)

* Fix state mismatch in behaviour.rs

* Add TODO
This commit is contained in:
Pierre Krieger
2020-05-13 19:50:01 +02:00
committed by GitHub
parent 6bdfae2bcb
commit 074d80f519
@@ -1123,25 +1123,25 @@ impl NetworkBehaviour for GenericProto {
);
}
// TODO: We switch the entire peer state to "disabled" because of possible
// race conditions involving the legacy substream.
// Once https://github.com/paritytech/substrate/issues/5670 is done, this
// should be changed to stay in the `Enabled` state.
debug!(target: "sub-libp2p", "Handler({:?}) <= Disable", source);
debug!(target: "sub-libp2p", "PSM <= Dropped({:?})", source);
self.peerset.dropped(source.clone());
self.events.push(NetworkBehaviourAction::NotifyHandler {
peer_id: source.clone(),
handler: NotifyHandler::One(connection),
handler: NotifyHandler::All,
event: NotifsHandlerIn::Disable,
});
let last = open.is_empty();
if last {
debug!(target: "sub-libp2p", "PSM <= Dropped({:?})", source);
self.peerset.dropped(source.clone());
*entry.into_mut() = PeerState::Disabled {
open,
banned_until: None
};
} else {
*entry.into_mut() = PeerState::Enabled { open };
}
*entry.into_mut() = PeerState::Disabled {
open,
banned_until: None
};
last
},