From f7d4fc8b454ed4564be16eaa44b73f0af33f162a Mon Sep 17 00:00:00 2001 From: Dmitry Murzin Date: Thu, 19 Sep 2024 20:47:49 +0300 Subject: [PATCH] perf: Reduce memory usage of `CommittedTransaction` Signed-off-by: Dmitry Murzin --- crates/iroha_core/src/block.rs | 2 +- .../src/query/predicate/predicate_atoms/block.rs | 8 ++++---- crates/iroha_data_model/src/transaction.rs | 2 +- crates/iroha_schema_gen/src/lib.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/iroha_core/src/block.rs b/crates/iroha_core/src/block.rs index f7241e71ce..98ff226687 100644 --- a/crates/iroha_core/src/block.rs +++ b/crates/iroha_core/src/block.rs @@ -232,7 +232,7 @@ mod pending { ); CommittedTransaction { value: tx, - error: Some(error), + error: Some(Box::new(error)), } } }) diff --git a/crates/iroha_data_model/src/query/predicate/predicate_atoms/block.rs b/crates/iroha_data_model/src/query/predicate/predicate_atoms/block.rs index 666ba288fc..c1d7ecb24b 100644 --- a/crates/iroha_data_model/src/query/predicate/predicate_atoms/block.rs +++ b/crates/iroha_data_model/src/query/predicate/predicate_atoms/block.rs @@ -1,7 +1,7 @@ //! This module contains predicates for block-related objects, mirroring [`crate::block`]. #[cfg(not(feature = "std"))] -use alloc::{format, string::String, vec::Vec}; +use alloc::{boxed::Box, format, string::String, vec::Vec}; use iroha_crypto::HashOf; use iroha_schema::IntoSchema; @@ -128,10 +128,10 @@ pub enum TransactionErrorPredicateBox { IsSome, } -impl_predicate_box!(Option: TransactionErrorPredicateBox); +impl_predicate_box!(Option>: TransactionErrorPredicateBox); -impl EvaluatePredicate> for TransactionErrorPredicateBox { - fn applies(&self, input: &Option) -> bool { +impl EvaluatePredicate>> for TransactionErrorPredicateBox { + fn applies(&self, input: &Option>) -> bool { match self { TransactionErrorPredicateBox::IsSome => input.is_some(), } diff --git a/crates/iroha_data_model/src/transaction.rs b/crates/iroha_data_model/src/transaction.rs index e268e46c13..eb7ea38be3 100644 --- a/crates/iroha_data_model/src/transaction.rs +++ b/crates/iroha_data_model/src/transaction.rs @@ -175,7 +175,7 @@ mod model { #[getset(skip)] pub value: SignedTransaction, /// Reason of rejection - pub error: Option, + pub error: Option>, } } diff --git a/crates/iroha_schema_gen/src/lib.rs b/crates/iroha_schema_gen/src/lib.rs index 276b328b68..79a80583ed 100644 --- a/crates/iroha_schema_gen/src/lib.rs +++ b/crates/iroha_schema_gen/src/lib.rs @@ -330,7 +330,7 @@ types!( Option, Option, Option, - Option, + Option>, Option, Option, Option,