Skip to content

Commit

Permalink
fix(ampd): optimize broadcaster (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcobb23 authored Feb 12, 2024
1 parent c88d8b0 commit 69124ee
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ampd/src/queue/queued_broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ where
let fee = broadcaster.estimate_fee(vec![msg.clone()]).await.change_context(Error::EstimateFee)?;

if fee.gas_limit + queue.gas_cost() >= self.batch_gas_limit {
interval.reset();
broadcast_all(&mut queue, &mut broadcaster).await?;
interval.reset();
}

let message_type = msg.type_url.clone();
Expand All @@ -135,10 +135,13 @@ where
);
}
},
_ = interval.tick() => broadcast_all(&mut queue, &mut broadcaster).await?,
_ = self.broadcast_rx.recv() => {
_ = interval.tick() => {
broadcast_all(&mut queue, &mut broadcaster).await?;
interval.reset();
},
_ = self.broadcast_rx.recv() => {
broadcast_all(&mut queue, &mut broadcaster).await?;
interval.reset();
},
}
}
Expand Down

0 comments on commit 69124ee

Please sign in to comment.