Skip to content

Commit

Permalink
chore: fix conflicts change
Browse files Browse the repository at this point in the history
  • Loading branch information
liyukun committed Nov 7, 2023
1 parent b1d3657 commit 4156363
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions crates/relayer/src/chain/ckb4ibc/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}/{}",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4156363

Please sign in to comment.