fn initiate_new_channel(
        &mut self,
        mut route: Route,
        return_address: Address,
    ) -> Result<Address, ChannelError> {
        // Remember who to notify when the channel is secure
        let pending_return = RouterAddress::from_address(return_address).unwrap();

        // Generate 2 channel addresses, one each for clear and cipher text
        let mut clear_address = String::from(CHANNEL_ZERO);
        let mut cipher_address = String::from(CHANNEL_ZERO);
        if let Some((clear, cipher)) = self.create_channel(ExchangerRole::Initiator) {
            clear_address = clear;
            cipher_address = cipher;
        }

        let channel = self.channels.get_mut(&cipher_address).unwrap();
        let mut channel = &mut *channel.lock().unwrap();
        channel.pending = Some(Message {
            onward_route: Route {
                addresses: vec![pending_return],
            },
            return_route: Route {
                addresses: vec![
                    RouterAddress::channel_router_address_from_str(&clear_address).unwrap(),
                ],
            },
            message_type: MessageType::None,
            message_body: vec![],
        });
        let ka_m1 = channel.agreement.process(&[])?;
        route
            .addresses
            .push(RouterAddress::channel_router_address_from_str(CHANNEL_ZERO).unwrap());
        let m = Message {
            onward_route: route,
            return_route: Route {
                addresses: vec![
                    RouterAddress::channel_router_address_from_str(&cipher_address).unwrap(),
                ],
            },
            message_type: MessageType::KeyAgreementM1,
            message_body: ka_m1,
        };
        self.router_tx.send(Router(RouterCommand::SendMessage(m)))?;
        Ok(Address::channel_address_from_string(&clear_address).unwrap())
    }
/// Initiates key exchange to create new secure channel over supplied route.
/// Upon completion of key exchange, a message is sent to return_address with
/// MessageType::None and the channel address in the return route.
Initiates key exchange to create new secure channel over supplied route.
Upon completion of key exchange, a message is sent to return_address with
MessageType::None and the channel address in the return route.
Initiates key exchange to create new secure channel over supplied route . Upon completion of key exchange a message is sent to return_address with MessageType :: None and the channel address in the return route .
fn initiate_new_channel(
        &mut self,
        mut route: Route,
        return_address: Address,
    ) -> Result<Address, ChannelError> {
        // Remember who to notify when the channel is secure
        let pending_return = RouterAddress::from_address(return_address).unwrap();
        // Generate 2 channel addresses, one each for clear and cipher text
        let mut clear_address = String::from(CHANNEL_ZERO);
        let mut cipher_address = String::from(CHANNEL_ZERO);
        if let Some((clear, cipher)) = self.create_channel(ExchangerRole::Initiator) {
            clear_address = clear;
            cipher_address = cipher;
        }
        let channel = self.channels.get_mut(&cipher_address).unwrap();
        let mut channel = &mut *channel.lock().unwrap();
        channel.pending = Some(Message {
            onward_route: Route {
                addresses: vec![pending_return],
            },
            return_route: Route {
                addresses: vec![
                    RouterAddress::channel_router_address_from_str(&clear_address).unwrap(),
                ],
            },
            message_type: MessageType::None,
            message_body: vec![],
        });
        let ka_m1 = channel.agreement.process(&[])?;
        route
            .addresses
            .push(RouterAddress::channel_router_address_from_str(CHANNEL_ZERO).unwrap());
        let m = Message {
            onward_route: route,
            return_route: Route {
                addresses: vec![
                    RouterAddress::channel_router_address_from_str(&cipher_address).unwrap(),
                ],
            },
            message_type: MessageType::KeyAgreementM1,
            message_body: ka_m1,
        };
        self.router_tx.send(Router(RouterCommand::SendMessage(m)))?;
        Ok(Address::channel_address_from_string(&clear_address).unwrap())
    }
fn initiate_new_channel ( & mut self , mut route : Route , return_address : Address , ) -> Result < Address , ChannelError > { // Remember who to notify when the channel is secure let pending_return = RouterAddress :: from_address ( return_address ) . unwrap ( ) ; // Generate 2 channel addresses, one each for clear and cipher text let mut clear_address = String :: from ( CHANNEL_ZERO ) ; let mut cipher_address = String :: from ( CHANNEL_ZERO ) ; if let Some ( ( clear , cipher ) ) = self . create_channel ( ExchangerRole :: Initiator ) { clear_address = clear ; cipher_address = cipher ; } let channel = self . channels . get_mut ( & cipher_address ) . unwrap ( ) ; let mut channel = & mut * channel . lock ( ) . unwrap ( ) ; channel . pending = Some ( Message { onward_route : Route { addresses : vec ! [ pending_return ] , } , return_route : Route { addresses : vec ! [ RouterAddress channel_router_address_from_str ( clear_address ) unwrap ( ) ] , } , message_type : MessageType :: None , message_body : vec ! [ ] , } ) ; let ka_m1 = channel . agreement . process ( & [ ] ) ? ; route . addresses . push ( RouterAddress :: channel_router_address_from_str ( CHANNEL_ZERO ) . unwrap ( ) ) ; let m = Message { onward_route : route , return_route : Route { addresses : vec ! [ RouterAddress channel_router_address_from_str ( cipher_address ) unwrap ( ) ] , } , message_type : MessageType :: KeyAgreementM1 , message_body : ka_m1 , } ; self . router_tx . send ( Router ( RouterCommand :: SendMessage ( m ) ) ) ? ; Ok ( Address :: channel_address_from_string ( & clear_address ) . unwrap ( ) ) }
Initiates key exchange to create new secure channel over supplied route.
Initiates key exchange to create new secure channel over supplied route .
&mut self
route
Route
return_address
Address