From b902c6fff04b27b5ebe098fd7cb884f5bf8c715e Mon Sep 17 00:00:00 2001 From: incrypto32 Date: Tue, 23 Apr 2024 22:53:28 +0400 Subject: [PATCH] chain/ethreum: do not send all headers when its init triggers only --- chain/ethereum/src/adapter.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chain/ethereum/src/adapter.rs b/chain/ethereum/src/adapter.rs index 6e9462bf000..f434d902e7e 100644 --- a/chain/ethereum/src/adapter.rs +++ b/chain/ethereum/src/adapter.rs @@ -304,6 +304,11 @@ impl bc::TriggerFilter for TriggerFilter { trigger_every_block, } = self.block.clone(); + // If polling_intervals is empty this will return true, else it will be true only if all intervals are 0 + // ie: All triggers are initialization handlers. We do not need firehose to send all block headers for + // initialization handlers + let has_initilization_triggers_only = polling_intervals.iter().all(|(_, i)| *i == 0); + let log_filters: Vec = self.log.into(); let mut call_filters: Vec = self.call.into(); call_filters.extend(Into::>::into(self.block)); @@ -315,7 +320,9 @@ impl bc::TriggerFilter for TriggerFilter { let combined_filter = CombinedFilter { log_filters, call_filters, - send_all_block_headers: trigger_every_block || !polling_intervals.is_empty(), + // We need firehose to send all block headers when `trigger_every_block` is true and when + // We have polling triggers which are not from initiallization handlers + send_all_block_headers: trigger_every_block || !has_initilization_triggers_only, }; vec![Any {