fn _recv(
        responses: &Arc<RwLock<ResponsesMap>>,
        wait_for: &'static str,
        timeout: Option<Duration>,
    ) -> Option<NetworkMessage> {
        let message_resp = {
            let mut lock = responses.write().unwrap();
            let message_resp = lock.entry(wait_for).or_default();
            Arc::clone(&message_resp)
        };

        let (lock, cvar) = &*message_resp;

        let mut messages = lock.lock().unwrap();
        while messages.is_empty() {
            match timeout {
                None => messages = cvar.wait(messages).unwrap(),
                Some(t) => {
                    let result = cvar.wait_timeout(messages, t).unwrap();
                    if result.1.timed_out() {
                        return None;
                    }
                    messages = result.0;
                }
            }
        }

        messages.pop()
    }
/// Wait for a specific incoming Bitcoin message, optionally with a timeout
Wait for a specific incoming Bitcoin message, optionally with a timeout
Wait for a specific incoming Bitcoin message optionally with a timeout
fn _recv(
        responses: &Arc<RwLock<ResponsesMap>>,
        wait_for: &'static str,
        timeout: Option<Duration>,
    ) -> Option<NetworkMessage> {
        let message_resp = {
            let mut lock = responses.write().unwrap();
            let message_resp = lock.entry(wait_for).or_default();
            Arc::clone(&message_resp)
        };
        let (lock, cvar) = &*message_resp;
        let mut messages = lock.lock().unwrap();
        while messages.is_empty() {
            match timeout {
                None => messages = cvar.wait(messages).unwrap(),
                Some(t) => {
                    let result = cvar.wait_timeout(messages, t).unwrap();
                    if result.1.timed_out() {
                        return None;
                    }
                    messages = result.0;
                }
            }
        }
        messages.pop()
    }
fn _recv ( responses : & Arc < RwLock < ResponsesMap > > , wait_for : & ' static str , timeout : Option < Duration > , ) -> Option < NetworkMessage > { let message_resp = { let mut lock = responses . write ( ) . unwrap ( ) ; let message_resp = lock . entry ( wait_for ) . or_default ( ) ; Arc :: clone ( & message_resp ) } ; let ( lock , cvar ) = & * message_resp ; let mut messages = lock . lock ( ) . unwrap ( ) ; while messages . is_empty ( ) { match timeout { None => messages = cvar . wait ( messages ) . unwrap ( ) , Some ( t ) => { let result = cvar . wait_timeout ( messages , t ) . unwrap ( ) ; if result . 1 . timed_out ( ) { return None ; } messages = result . 0 ; } } } messages . pop ( ) }
Wait for a specific incoming Bitcoin message, optionally with a timeout
Wait for a specific incoming Bitcoin message optionally with a timeout
responses
&Arc<RwLock<ResponsesMap>>
wait_for
&'static str
timeout
Option<Duration>
responses
&Arc<RwLock<ResponsesMap>>
wait_for
&'static str
timeout
Option<Duration>