Skip to content

Commit

Permalink
Merge pull request #2588 from get10101/fix/do-not-create-dlc-protocol…
Browse files Browse the repository at this point in the history
…-for-force-closed-channels

fix: Do not create dlc protocol entry for force closed channels
  • Loading branch information
holzeis authored May 31, 2024
2 parents a544aa7 + 357a9f5 commit df7be13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
16 changes: 7 additions & 9 deletions coordinator/src/node/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,19 @@ pub struct DlcChannel {
}

impl Node {
pub async fn close_dlc_channel(
&self,
channel_id: DlcChannelId,
is_force_close: bool,
) -> Result<()> {
pub async fn force_close_dlc_channel(&self, channel_id: DlcChannelId) -> Result<()> {
self.inner.close_dlc_channel(channel_id, true).await?;
Ok(())
}

pub async fn close_dlc_channel(&self, channel_id: DlcChannelId) -> Result<()> {
let channel = self.inner.get_dlc_channel_by_id(&channel_id)?;
let previous_id = channel
.get_reference_id()
.map(ProtocolId::try_from)
.transpose()?;

let protocol_id = self
.inner
.close_dlc_channel(channel_id, is_force_close)
.await?;
let protocol_id = self.inner.close_dlc_channel(channel_id, false).await?;

let protocol_executor = dlc_protocol::DlcProtocolExecutor::new(self.pool.clone());
protocol_executor.start_dlc_protocol(
Expand Down
10 changes: 5 additions & 5 deletions coordinator/src/routes/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ pub async fn close_channel(

tracing::info!(channel_id = %channel_id_string, "Attempting to close channel");

state
.node
.close_dlc_channel(channel_id, params.force.unwrap_or_default())
.await
.map_err(|e| AppError::InternalServerError(format!("{e:#}")))?;
match params.force.unwrap_or_default() {
true => state.node.force_close_dlc_channel(channel_id).await,
false => state.node.close_dlc_channel(channel_id).await,
}
.map_err(|e| AppError::InternalServerError(format!("{e:#}")))?;

Ok(())
}
Expand Down

0 comments on commit df7be13

Please sign in to comment.