swarm/: Allow disconnecting from Swarm and NetworkBehaviour (#2110)

Add `ExpandedSwarm::disconnect_peer_id` and
`NetworkBehaviourAction::CloseConnection` to close connections to a specific
peer via an `ExpandedSwarm` or `NetworkBehaviour`.

Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
Sergey O. Boyko
2021-07-03 00:35:51 +07:00
committed by GitHub
parent f9491e7e81
commit 4eb0659e4d
7 changed files with 376 additions and 40 deletions

View File

@ -657,7 +657,9 @@ where
| NetworkBehaviourAction::NotifyHandler { peer_id, handler, event } =>
NetworkBehaviourAction::NotifyHandler { peer_id, handler, event },
| NetworkBehaviourAction::ReportObservedAddr { address, score } =>
NetworkBehaviourAction::ReportObservedAddr { address, score }
NetworkBehaviourAction::ReportObservedAddr { address, score },
| NetworkBehaviourAction::CloseConnection { peer_id, connection } =>
NetworkBehaviourAction::CloseConnection { peer_id, connection }
};
return Poll::Ready(event)