From ec7f5648d1b8ba743ffd13ff03476e01229a785a Mon Sep 17 00:00:00 2001 From: tbro Date: Tue, 2 Jul 2024 18:53:12 +0300 Subject: [PATCH] add `accounts` method to `IterableFeeInfo` --- types/src/v0/impls/fee_info.rs | 8 ++++++++ types/src/v0/impls/state.rs | 6 +----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/src/v0/impls/fee_info.rs b/types/src/v0/impls/fee_info.rs index c81cc3478..0adf61ec3 100644 --- a/types/src/v0/impls/fee_info.rs +++ b/types/src/v0/impls/fee_info.rs @@ -60,11 +60,14 @@ impl FeeInfo { } } +/// Methods for use w/ Vec pub trait IterableFeeInfo { fn amount(&self) -> Option; + fn accounts(&self) -> Vec; } impl IterableFeeInfo for Vec { + /// Get sum of fee amounts fn amount(&self) -> Option { self.iter() // getting the u64 tests that the value fits @@ -73,6 +76,11 @@ impl IterableFeeInfo for Vec { .and_then(|amounts| amounts.iter().try_fold(0u64, |acc, n| acc.checked_add(*n))) .map(|n| FeeAmount::from(n)) } + + /// Get a `Vec` of all fee accounts + fn accounts(&self) -> Vec { + self.iter().map(|entry| entry.account).collect() + } } impl From> for FeeInfo { diff --git a/types/src/v0/impls/state.rs b/types/src/v0/impls/state.rs index 305a7553a..b34caf5c2 100644 --- a/types/src/v0/impls/state.rs +++ b/types/src/v0/impls/state.rs @@ -338,11 +338,7 @@ impl ValidatedState { // in this block. let missing_accounts = self.forgotten_accounts( [ - proposed_header - .fee_info() - .iter() - .map(|entry| entry.account) - .collect::>(), + proposed_header.fee_info().accounts(), vec![chain_config.fee_recipient], l1_deposits .iter()