pub fn release(&self, peer_id: PeerId) -> bool {
        let mut leases = self.leases.lock().unwrap();
        match leases.remove_peer(peer_id) {
            Ok(semaphores) => {
                // Keep book about all peers, those locks have been acquired, so we can notify their pending
                // requests.
                let mut resolved_peers = Vec::new();
                for semaphore in semaphores {
                    let full_count = self
                        .semaphores
                        .get(&semaphore)
                        .expect("An active semaphore must always be configured");
                    leases.resolve_pending(&semaphore, *full_count, &mut resolved_peers);
                }
                drop(leases); // Don't hold this longer than we need to.
                self.wakers.resolve_with(&resolved_peers, Ok(()));
                true
            }
            Err(ThrottleError::UnknownPeer) => {
                warn!("Deletion of unknown peer.");
                false
            }
            Err(_) => panic!("Remove can only fail with 'UnknownPeer'."),
        }
    }
/// Removes a peer from bookeeping and releases all acquired leases.
///
/// Returns `false` should the peer not be found and `true` otherwise. `false` could occur due
/// to e.g. the peer already being removed by litter collection.
Removes a peer from bookeeping and releases all acquired leases.
Returns `false` should the peer not be found and `true` otherwise. `false` could occur due
to e.g. the peer already being removed by litter collection.
Removes a peer from bookeeping and releases all acquired leases . Returns ` false ` should the peer not be found and ` true ` otherwise . ` false ` could occur due to e . g . the peer already being removed by litter collection .
pub fn release(&self, peer_id: PeerId) -> bool {
        let mut leases = self.leases.lock().unwrap();
        match leases.remove_peer(peer_id) {
            Ok(semaphores) => {
                // Keep book about all peers, those locks have been acquired, so we can notify their pending
                // requests.
                let mut resolved_peers = Vec::new();
                for semaphore in semaphores {
                    let full_count = self
                        .semaphores
                        .get(&semaphore)
                        .expect("An active semaphore must always be configured");
                    leases.resolve_pending(&semaphore, *full_count, &mut resolved_peers);
                }
                drop(leases); // Don't hold this longer than we need to.
                self.wakers.resolve_with(&resolved_peers, Ok(()));
                true
            }
            Err(ThrottleError::UnknownPeer) => {
                warn!("Deletion of unknown peer.");
                false
            }
            Err(_) => panic!("Remove can only fail with 'UnknownPeer'."),
        }
    }
pub fn release ( & self , peer_id : PeerId ) -> bool { let mut leases = self . leases . lock ( ) . unwrap ( ) ; match leases . remove_peer ( peer_id ) { Ok ( semaphores ) => { // Keep book about all peers, those locks have been acquired, so we can notify their pending // requests. let mut resolved_peers = Vec :: new ( ) ; for semaphore in semaphores { let full_count = self . semaphores . get ( & semaphore ) . expect ( " " ) ; leases . resolve_pending ( & semaphore , * full_count , & mut resolved_peers ) ; } drop ( leases ) ; // Don't hold this longer than we need to. self . wakers . resolve_with ( & resolved_peers , Ok ( ( ) ) ) ; true } Err ( ThrottleError :: UnknownPeer ) => { warn ! ( " " ) ; false } Err ( _ ) => panic ! ( " " ) , } }
Removes a peer from bookeeping and releases all acquired leases.
Removes a peer from bookeeping and releases all acquired leases .
&self
peer_id
PeerId
&self
peer_id
PeerId