pub fn subscribe_to_call_confirmed<P: Pair>(api: Api<P>) -> H256
where
    MultiSignature: From<P::Signature>,
{
    let (events_in, events_out) = channel();

    let _eventsubscriber = thread::Builder::new()
        .name("eventsubscriber".to_owned())
        .spawn(move || {
            api.subscribe_events(events_in.clone()).unwrap();
        })
        .unwrap();

    println!("waiting for confirmation event...");
    loop {
        let event_str = events_out.recv().unwrap();

        let _unhex = Vec::from_hex(event_str).unwrap();
        let mut _er_enc = _unhex.as_slice();
        let _events = Vec::<frame_system::EventRecord<Event, Hash>>::decode(&mut _er_enc);
        if let Ok(evts) = _events {
            for evr in &evts {
                info!("received event {:?}", evr.event);
                if let Event::pallet_substratee_registry(pe) = &evr.event {
                    if let my_node_runtime::pallet_substratee_registry::RawEvent::CallConfirmed(
                        sender,
                        payload,
                    ) = &pe
                    {
                        println!("[+] Received confirm call from {}", sender);
                        return payload.clone().to_owned();
                    } else {
                        debug!(
                            "received unknown event from SubstraTeeRegistry: {:?}",
                            evr.event
                        )
                    }
                }
            }
        }
    }
}
// subscribes to he pallet_substratee_registry events of type CallConfirmed
subscribes to he pallet_substratee_registry events of type CallConfirmed
subscribes to he pallet_substratee_registry events of type CallConfirmed
pub fn subscribe_to_call_confirmed<P: Pair>(api: Api<P>) -> H256
where
    MultiSignature: From<P::Signature>,
{
    let (events_in, events_out) = channel();
    let _eventsubscriber = thread::Builder::new()
        .name("eventsubscriber".to_owned())
        .spawn(move || {
            api.subscribe_events(events_in.clone()).unwrap();
        })
        .unwrap();
    println!("waiting for confirmation event...");
    loop {
        let event_str = events_out.recv().unwrap();
        let _unhex = Vec::from_hex(event_str).unwrap();
        let mut _er_enc = _unhex.as_slice();
        let _events = Vec::<frame_system::EventRecord<Event, Hash>>::decode(&mut _er_enc);
        if let Ok(evts) = _events {
            for evr in &evts {
                info!("received event {:?}", evr.event);
                if let Event::pallet_substratee_registry(pe) = &evr.event {
                    if let my_node_runtime::pallet_substratee_registry::RawEvent::CallConfirmed(
                        sender,
                        payload,
                    ) = &pe
                    {
                        println!("[+] Received confirm call from {}", sender);
                        return payload.clone().to_owned();
                    } else {
                        debug!(
                            "received unknown event from SubstraTeeRegistry: {:?}",
                            evr.event
                        )
                    }
                }
            }
        }
    }
}
pub fn subscribe_to_call_confirmed < P : Pair > ( api : Api < P > ) -> H256 where MultiSignature : From < P :: Signature > , { let ( events_in , events_out ) = channel ( ) ; let _eventsubscriber = thread :: Builder :: new ( ) . name ( " " . to_owned ( ) ) . spawn ( move | | { api . subscribe_events ( events_in . clone ( ) ) . unwrap ( ) ; } ) . unwrap ( ) ; println ! ( " " ) ; loop { let event_str = events_out . recv ( ) . unwrap ( ) ; let _unhex = Vec :: from_hex ( event_str ) . unwrap ( ) ; let mut _er_enc = _unhex . as_slice ( ) ; let _events = Vec :: < frame_system :: EventRecord < Event , Hash > > :: decode ( & mut _er_enc ) ; if let Ok ( evts ) = _events { for evr in & evts { info ! ( " " evr event ) ; if let Event :: pallet_substratee_registry ( pe ) = & evr . event { if let my_node_runtime :: pallet_substratee_registry :: RawEvent :: CallConfirmed ( sender , payload , ) = & pe { println ! ( " " sender ) ; return payload . clone ( ) . to_owned ( ) ; } else { debug ! ( " " evr event ) } } } } } }
subscribes to he pallet_substratee_registry events of type CallConfirmed
subscribes to he pallet_substratee_registry events of type CallConfirmed
api
Api<P>
api
Api<P>