From a83de80afa404caf55eb1b83b218fc702e57c82d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 10 Apr 2023 18:09:09 +0200 Subject: [PATCH] chore: manual default for PostState (#2173) --- crates/storage/provider/src/post_state.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/storage/provider/src/post_state.rs b/crates/storage/provider/src/post_state.rs index deb4cdfe43..30a00d4bbf 100644 --- a/crates/storage/provider/src/post_state.rs +++ b/crates/storage/provider/src/post_state.rs @@ -168,7 +168,7 @@ impl Change { /// Since most [PostState]s in reth are for multiple blocks it is better to pre-allocate capacity /// for receipts and changes, which [PostState::new] does, and thus it (or /// [PostState::with_tx_capacity]) should be preferred to using the [Default] implementation. -#[derive(Debug, Default, Clone, Eq, PartialEq)] +#[derive(Debug, Clone, Eq, PartialEq)] pub struct PostState { /// The ID of the current transition. current_transition_id: TransitionId, @@ -204,7 +204,7 @@ const PREALLOC_CHANGES_SIZE: usize = 256 * BEST_GUESS_CHANGES_PER_TX; impl PostState { /// Create an empty [PostState]. pub fn new() -> Self { - Self { changes: Vec::with_capacity(PREALLOC_CHANGES_SIZE), ..Default::default() } + Self::default() } /// Create an empty [PostState] with pre-allocated space for a certain amount of transactions. @@ -595,6 +595,19 @@ impl PostState { } } +impl Default for PostState { + fn default() -> Self { + Self { + current_transition_id: 0, + accounts: Default::default(), + storage: Default::default(), + changes: Vec::with_capacity(PREALLOC_CHANGES_SIZE), + bytecode: Default::default(), + receipts: vec![], + } + } +} + #[cfg(test)] mod tests { use super::*;