From 975ff5a4275e13cd6037d13301d8a089fae31c31 Mon Sep 17 00:00:00 2001 From: Dori Medini Date: Sun, 17 Nov 2024 18:52:33 +0200 Subject: [PATCH] refactor(blockifier): move logic to function --- crates/blockifier/src/execution/call_info.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/blockifier/src/execution/call_info.rs b/crates/blockifier/src/execution/call_info.rs index d67271d23d..e6f8d84693 100644 --- a/crates/blockifier/src/execution/call_info.rs +++ b/crates/blockifier/src/execution/call_info.rs @@ -157,6 +157,16 @@ impl CallInfo { CallInfoIter { call_infos } } + fn specific_event_summary(&self) -> EventSummary { + let mut event_summary = + EventSummary { n_events: self.execution.events.len(), ..Default::default() }; + for OrderedEvent { event, .. } in self.execution.events.iter() { + event_summary.total_event_data_size += u64_from_usize(event.data.0.len()); + event_summary.total_event_keys += u64_from_usize(event.keys.len()); + } + event_summary + } + pub fn summarize(&self) -> ExecutionSummary { let mut executed_class_hashes: HashSet = HashSet::new(); let mut visited_storage_entries: HashSet = HashSet::new(); @@ -186,14 +196,7 @@ impl CallInfo { ); // Events. - event_summary.n_events += call_info.execution.events.len(); - for OrderedEvent { event, .. } in call_info.execution.events.iter() { - // TODO(barak: 18/03/2024): Once we start charging per byte - // change to num_bytes_keys - // and num_bytes_data. - event_summary.total_event_data_size += u64_from_usize(event.data.0.len()); - event_summary.total_event_keys += u64_from_usize(event.keys.len()); - } + event_summary += call_info.specific_event_summary(); } ExecutionSummary {