Skip to content

Commit a47e648

Browse files
authored
fix: Unmark subnet as needed in peer manager (#515)
When getting a `Leave` event form the subnet service, we tell Gossipsub to unsubscribe, but do not the peer manager, who keeps searching peers for it. Remove the subnet from `needed_subnets`.
1 parent 5b4a5ad commit a47e648

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

anchor/network/src/network.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ impl<R: MessageReceiver> Network<R> {
456456
}
457457
SubnetEvent::Leave(subnet) => {
458458
self.gossipsub().unsubscribe(&subnet_to_topic(subnet));
459+
self.peer_manager().leave_subnet(subnet);
459460
(subnet, false)
460461
}
461462
SubnetEvent::RateUpdate(subnet, message_rate) => {

anchor/network/src/peer_manager/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ impl PeerManager {
8080
)
8181
}
8282

83+
/// Leave subnet
84+
pub fn leave_subnet(&mut self, subnet_id: SubnetId) {
85+
self.needed_subnets.remove(&subnet_id);
86+
}
87+
8388
/// Perform heartbeat and return actions if needed
8489
pub fn heartbeat(&mut self) -> Option<ConnectActions> {
8590
info!(

0 commit comments

Comments
 (0)