Skip to content

Commit

Permalink
Send TxComplete asap to keep message order
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Jun 11, 2024
1 parent 79f6def commit 4f4a0ef
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/ckb/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2350,16 +2350,21 @@ impl ChannelActorState {
);

if is_complete {
// We need to send a SendPcnMessage command here (instead of a ControlPcnChannel),
// to guarantee that the TxComplete message immediately is sent to the network actor.
// Otherwise, it is possible that when the network actor is processing ControlPcnChannel,
// it receives another SendPcnMessage command, and that message (e.g. CommitmentSigned)
// is processed first, thus breaking the order of messages.
network
.send_message(NetworkActorMessage::new_command(
NetworkActorCommand::ControlPcnChannel(ChannelCommandWithId {
channel_id: self.get_id(),
command: ChannelCommand::TxCollaborationCommand(
TxCollaborationCommand::TxComplete(TxCompleteCommand {}),
),
}),
NetworkActorCommand::SendPcnMessage(PCNMessageWithPeerId::new(
self.peer_id.clone(),
PCNMessage::TxComplete(TxComplete {
channel_id: self.get_id(),
}),
)),
))
.expect("network alive");
.expect("network actor alive");
let old_flags = match self.state {
ChannelState::CollaboratingFundingTx(flags) => flags,
_ => {
Expand Down

0 comments on commit 4f4a0ef

Please sign in to comment.