From e67a136013f6f975900c53ef0b026fe2965826f3 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 5 Nov 2020 14:26:29 +0100 Subject: [PATCH] Renaming channel id for peerd --- src/channeld/runtime.rs | 7 +++++-- src/peerd/runtime.rs | 22 ++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/channeld/runtime.rs b/src/channeld/runtime.rs index 58f3da8..78b16ee 100644 --- a/src/channeld/runtime.rs +++ b/src/channeld/runtime.rs @@ -570,6 +570,11 @@ impl Runtime { ServiceId::Lnpd, Request::UpdateChannelId(self.channel_id), )?; + self.send_ctl( + senders, + self.peer_service.clone(), + Request::UpdateChannelId(self.channel_id), + )?; self.identity = self.channel_id.into(); let msg = format!( "{} set to {}", @@ -750,8 +755,6 @@ impl Runtime { info!("{}", msg); let _ = self.report_progress_to(senders, &enquirer, msg); - self.update_channel_id(senders)?; - Ok(funding_created) } diff --git a/src/peerd/runtime.rs b/src/peerd/runtime.rs index e18dc80..ea9a755 100644 --- a/src/peerd/runtime.rs +++ b/src/peerd/runtime.rs @@ -173,7 +173,7 @@ pub struct Runtime { local_socket: Option, remote_socket: InetSocketAddr, - routing: HashMap, + routing: HashMap, sender: PeerSender, connect: bool, @@ -245,17 +245,13 @@ impl Runtime { match &request { Request::PeerMessage(Messages::FundingSigned( message::FundingSigned { channel_id, .. }, - )) - | Request::PeerMessage(Messages::FundingLocked( - message::FundingLocked { channel_id, .. }, )) => { debug!( "Renaming channeld service from temporary id {:#} to channel id #{:#}", source, channel_id ); self.routing.remove(&source); - self.routing - .insert(channel_id.clone().into(), MessageFilter {}); + self.routing.insert(channel_id.clone().into(), source); } _ => {} } @@ -287,6 +283,15 @@ impl Runtime { request: Request, ) -> Result<(), Error> { match request { + Request::UpdateChannelId(channel_id) => { + debug!( + "Renaming channeld service from temporary id {:#} to channel id #{:#}", + source, channel_id + ); + self.routing.remove(&source); + self.routing.insert(channel_id.clone().into(), source); + } + Request::GetInfo => { let info = PeerInfo { local_id: self.local_id, @@ -381,7 +386,7 @@ impl Runtime { Request::PeerMessage(Messages::AcceptChannel(accept_channel)) => { let channeld: ServiceId = accept_channel.temporary_channel_id.into(); - self.routing.insert(channeld.clone(), MessageFilter {}); + self.routing.insert(channeld.clone(), channeld.clone()); senders.send_to( ServiceBus::Msg, self.identity(), @@ -425,10 +430,11 @@ impl Runtime { | Request::PeerMessage(Messages::AssignFunds( message::AssignFunds { channel_id, .. }, )) => { + let channeld: ServiceId = channel_id.clone().into(); senders.send_to( ServiceBus::Msg, self.identity(), - channel_id.clone().into(), + self.routing.get(&channeld).cloned().unwrap_or(channeld), request, )?; }