scatter_net/legacy/net/implementations/
terminate.rs1use iroh::endpoint::VarInt;
2
3use crate::{Peer, PeerGroup, ScatterNet, Terminate};
4
5impl<E, R> Terminate<E, R> for ScatterNet
6where
7 E: Into<VarInt> + Send,
8 R: AsRef<[u8]> + Send,
9{
10 fn terminate(&self, error_code: E, reason: &R) {
11 let error_code = error_code.into();
12 let reason = reason.as_ref();
13
14 let peer_groups = self.read().peer_groups.clone();
15
16 for peer_group in peer_groups {
17 PeerGroup::terminate(&peer_group, error_code, &reason);
18 }
19
20 let peers: Vec<Peer> = self.read().peers.values().cloned().collect();
21
22 for peer in peers {
23 Peer::terminate(&peer, error_code, &reason);
24 }
25 }
26}