From 415636332e023296c9e7b3ee7ddb766d06ac67c0 Mon Sep 17 00:00:00 2001 From: liyukun Date: Tue, 7 Nov 2023 15:38:13 +0800 Subject: [PATCH] chore: fix conflicts change --- crates/relayer/src/chain/ckb4ibc/monitor.rs | 45 +++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/crates/relayer/src/chain/ckb4ibc/monitor.rs b/crates/relayer/src/chain/ckb4ibc/monitor.rs index 48445945..c60657af 100644 --- a/crates/relayer/src/chain/ckb4ibc/monitor.rs +++ b/crates/relayer/src/chain/ckb4ibc/monitor.rs @@ -401,26 +401,31 @@ impl Ckb4IbcEventMonitor { let useless_packets = &mut self.useless_write_ack_packets; let events = ibc_packets .into_iter() - .filter(|(((packet, _), tx), (block_number, cell_input))| { - // if a block contains more than one WriteAck cells, useless_packets won't save all of them, - // but every packet cells will be scanned repeatedly, after the previous WriteAck cell is consumed, - // the other WriteAck cells which share the save block_number will be stored then - if packet.status == PacketStatus::WriteAck - && !useless_packets.contains_key(block_number) - { - useless_packets.insert(*block_number, (packet.clone(), cell_input.clone())); - } - if packet.status == PacketStatus::Ack - || packet.status == PacketStatus::Recv - || self.cache_set.read().unwrap().has(tx) - { - return false; - } - self.cache_set.write().unwrap().insert(tx.clone()); - true - }) + .filter( + |(((packet, _), tx), (block_number, cell_input, capacity))| { + // if a block contains more than one WriteAck cells, useless_packets won't save all of them, + // but every packet cells will be scanned repeatedly, after the previous WriteAck cell is consumed, + // the other WriteAck cells which share the save block_number will be stored then + if packet.status == PacketStatus::WriteAck + && !useless_packets.contains_key(block_number) + { + useless_packets.insert( + *block_number, + (packet.clone(), cell_input.clone(), *capacity), + ); + } + if packet.status == PacketStatus::Ack + || packet.status == PacketStatus::Recv + || self.cache_set.read().unwrap().has(tx) + { + return false; + } + self.cache_set.write().unwrap().insert(tx.clone()); + true + }, + ) .map( - |(((packet, _), tx), (block_number, cell_input, capacity))| match packet.status { + |(((packet, _), tx), (block_number, _, _))| match packet.status { PacketStatus::Send => { info!( "🫡 {} received SendPacket({}) event, from {}/{} to {}/{}", @@ -449,8 +454,6 @@ impl Ckb4IbcEventMonitor { packet.packet.destination_channel_id, packet.packet.destination_port_id, ); - useless_packets - .insert(block_number, (packet.clone(), cell_input, capacity)); IbcEventWithHeight { event: IbcEvent::WriteAcknowledgement(WriteAcknowledgement { ack: packet