Skip to content

Commit

Permalink
chain/ethreum: do not send all headers when its init triggers only
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Apr 27, 2024
1 parent 428f866 commit b902c6f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion chain/ethereum/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ impl bc::TriggerFilter<Chain> 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<LogFilter> = self.log.into();
let mut call_filters: Vec<CallToFilter> = self.call.into();
call_filters.extend(Into::<Vec<CallToFilter>>::into(self.block));
Expand All @@ -315,7 +320,9 @@ impl bc::TriggerFilter<Chain> 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 {
Expand Down

0 comments on commit b902c6f

Please sign in to comment.