Skip to content

Commit 4f4a0ef

Browse files
committed
Send TxComplete asap to keep message order
1 parent 79f6def commit 4f4a0ef

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/ckb/channel.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,16 +2350,21 @@ impl ChannelActorState {
23502350
);
23512351

23522352
if is_complete {
2353+
// We need to send a SendPcnMessage command here (instead of a ControlPcnChannel),
2354+
// to guarantee that the TxComplete message immediately is sent to the network actor.
2355+
// Otherwise, it is possible that when the network actor is processing ControlPcnChannel,
2356+
// it receives another SendPcnMessage command, and that message (e.g. CommitmentSigned)
2357+
// is processed first, thus breaking the order of messages.
23532358
network
23542359
.send_message(NetworkActorMessage::new_command(
2355-
NetworkActorCommand::ControlPcnChannel(ChannelCommandWithId {
2356-
channel_id: self.get_id(),
2357-
command: ChannelCommand::TxCollaborationCommand(
2358-
TxCollaborationCommand::TxComplete(TxCompleteCommand {}),
2359-
),
2360-
}),
2360+
NetworkActorCommand::SendPcnMessage(PCNMessageWithPeerId::new(
2361+
self.peer_id.clone(),
2362+
PCNMessage::TxComplete(TxComplete {
2363+
channel_id: self.get_id(),
2364+
}),
2365+
)),
23612366
))
2362-
.expect("network alive");
2367+
.expect("network actor alive");
23632368
let old_flags = match self.state {
23642369
ChannelState::CollaboratingFundingTx(flags) => flags,
23652370
_ => {

0 commit comments

Comments
 (0)