Skip to content

Commit

Permalink
only clone necessary sender
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Jun 9, 2021
1 parent 44efd96 commit 3b8f772
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions jormungandr/src/notifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,18 @@ impl MessageProcessor {
.await;
});

let tip_sender = self.tip_sender;
let block_sender = self.block_sender;
let mempool_sender = self.mempool_sender;

while let Some(input) = queue.next().await {
let tip_sender = Arc::clone(&tip_sender);
let block_sender = Arc::clone(&block_sender);
let mempool_sender = Arc::clone(&mempool_sender);

match input {
Message::NewBlock(block) => {
let block_sender = Arc::clone(&self.block_sender);
info.spawn("notifier broadcast block", async move {
if let Err(_err) = block_sender.send(Block {
content: block.serialize_as_vec().unwrap(),
}) {}
});
}
Message::NewTip(block_id) => {
let tip_sender = Arc::clone(&self.tip_sender);
info.spawn("notifier broadcast new tip", async move {
if let Err(_err) = tip_sender.send(BlockId {
content: block_id.serialize_as_vec().unwrap(),
Expand All @@ -115,6 +109,7 @@ impl MessageProcessor {
});
}
Message::FragmentLog(fragment_id, status) => {
let mempool_sender = Arc::clone(&self.mempool_sender);
info.spawn("notifier broadcast mempool update", async move {
let event = match status {
FragmentStatus::Pending => {
Expand Down

0 comments on commit 3b8f772

Please sign in to comment.