mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
ws: SwarmControlMessage::ConnectionClosed: use Vec for info hashes
This commit is contained in:
parent
4c831643b1
commit
36954e5f48
3 changed files with 22 additions and 18 deletions
|
|
@ -599,19 +599,23 @@ impl ConnectionCleanupData {
|
|||
config: &Config,
|
||||
control_message_senders: Rc<Senders<SwarmControlMessage>>,
|
||||
) {
|
||||
// Use RefCell::take to avoid issues with Rc borrow across await
|
||||
let announced_info_hashes = self.announced_info_hashes.take();
|
||||
|
||||
// Tell swarm workers to remove peer
|
||||
for (info_hash, peer_id) in announced_info_hashes.into_iter() {
|
||||
let message = SwarmControlMessage::ConnectionClosed {
|
||||
info_hash,
|
||||
peer_id,
|
||||
ip_version: self.ip_version,
|
||||
};
|
||||
let mut announced_info_hashes = HashMap::new();
|
||||
|
||||
for (info_hash, peer_id) in self.announced_info_hashes.take().into_iter() {
|
||||
let consumer_index = calculate_in_message_consumer_index(&config, info_hash);
|
||||
|
||||
announced_info_hashes
|
||||
.entry(consumer_index)
|
||||
.or_insert(Vec::new())
|
||||
.push((info_hash, peer_id));
|
||||
}
|
||||
|
||||
for (consumer_index, announced_info_hashes) in announced_info_hashes.into_iter() {
|
||||
let message = SwarmControlMessage::ConnectionClosed {
|
||||
ip_version: self.ip_version,
|
||||
announced_info_hashes,
|
||||
};
|
||||
|
||||
control_message_senders
|
||||
.send_to(consumer_index, message)
|
||||
.await
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue