From b140e9f5b980a058f799cbbe55ebf7b63ac104e9 Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop <105209995+Qwerty5Uiop@users.noreply.github.com> Date: Tue, 23 Jul 2024 16:16:27 +0400 Subject: [PATCH] chore: Token transfers broadcast optimization (#10465) --- .../lib/block_scout_web/notifier.ex | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/notifier.ex b/apps/block_scout_web/lib/block_scout_web/notifier.ex index f364dfa64e..a25f812120 100644 --- a/apps/block_scout_web/lib/block_scout_web/notifier.ex +++ b/apps/block_scout_web/lib/block_scout_web/notifier.ex @@ -177,16 +177,13 @@ defmodule BlockScoutWeb.Notifier do def handle_event({:chain_event, :token_transfers, :realtime, all_token_transfers}) do all_token_transfers_full = all_token_transfers - |> Enum.map( - &(&1 - |> Repo.preload( - DenormalizationHelper.extend_transaction_preload([ - :token, - :transaction, - from_address: [:names, :smart_contract, :proxy_implementations], - to_address: [:names, :smart_contract, :proxy_implementations] - ]) - )) + |> Repo.preload( + DenormalizationHelper.extend_transaction_preload([ + :token, + :transaction, + from_address: [:names, :smart_contract, :proxy_implementations], + to_address: [:names, :smart_contract, :proxy_implementations] + ]) ) transfers_by_token = Enum.group_by(all_token_transfers_full, fn tt -> to_string(tt.token_contract_address_hash) end)