Skip to content

Commit

Permalink
add staging tlc operations
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Nov 25, 2024
1 parent 9a003a5 commit 6b62e81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,12 @@ impl TLCId {
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum TlcOperation {
AddTlc(AddTlc),
RemoveTlc(RemoveTlc),
}

#[serde_as]
#[derive(Clone, Serialize, Deserialize)]
pub struct ChannelActorState {
Expand Down Expand Up @@ -2064,6 +2070,9 @@ pub struct ChannelActorState {
// The maximum number of tlcs that we can accept.
pub max_tlc_number_in_flight: u64,

// The stagning tlc operations, we will process them when receiving the commitment_signed message.
pub staging_tlc_operations: Vec<TlcOperation>,

// Below are fields that are only usable after the channel is funded,
// (or at some point of the state).

Expand Down Expand Up @@ -2797,6 +2806,7 @@ impl ChannelActorState {
commitment_delay_epoch,
funding_fee_rate,
id: channel_id,
staging_tlc_operations: vec![],
tlc_ids: Default::default(),
tlcs: Default::default(),
local_shutdown_script: local_shutdown_script,
Expand Down Expand Up @@ -2860,6 +2870,7 @@ impl ChannelActorState {
commitment_delay_epoch,
funding_fee_rate,
id: temp_channel_id,
staging_tlc_operations: vec![],
tlc_ids: Default::default(),
tlcs: Default::default(),
signer,
Expand Down Expand Up @@ -4139,6 +4150,7 @@ impl ChannelActorState {
}
Ok(())
}

fn check_for_tlc_update(&self, add_tlc_amount: Option<u128>) -> ProcessingChannelResult {
match self.state {
ChannelState::ChannelReady() => {}
Expand Down
2 changes: 1 addition & 1 deletion src/fiber/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ impl TryFrom<molecule_fiber::ClosingSigned> for ClosingSigned {
}
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct AddTlc {
pub channel_id: Hash256,
pub tlc_id: u64,
Expand Down

0 comments on commit 6b62e81

Please sign in to comment.