From c7bd281974bb76fd1bb7bd94bdc7bb2757369153 Mon Sep 17 00:00:00 2001 From: Yong Kang Date: Mon, 24 Nov 2025 09:15:15 +0000 Subject: [PATCH] feat(chain-state): constructors for ExecutedBlock for trie data for builders --- crates/chain-state/src/in_memory.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/chain-state/src/in_memory.rs b/crates/chain-state/src/in_memory.rs index 5da10e1a2d..28b138320b 100644 --- a/crates/chain-state/src/in_memory.rs +++ b/crates/chain-state/src/in_memory.rs @@ -741,6 +741,29 @@ impl Default for ExecutedBlock { } impl ExecutedBlock { + /// Create a new [`ExecutedBlock`] with deferred trie data. + /// + /// Use this constructor when trie data will be computed asynchronously. + pub const fn new( + recovered_block: Arc>, + execution_output: Arc>, + trie_data: DeferredTrieData, + ) -> Self { + Self { recovered_block, execution_output, trie_data } + } + + /// Create a new [`ExecutedBlock`] with already-computed trie data. + /// + /// Use this constructor when trie data is available immediately. + /// The trie data will be wrapped in a ready [`DeferredTrieData`] handle. + pub fn with_trie_data( + recovered_block: Arc>, + execution_output: Arc>, + trie_data: ComputedTrieData, + ) -> Self { + Self { recovered_block, execution_output, trie_data: DeferredTrieData::ready(trie_data) } + } + /// Returns a reference to an inner [`SealedBlock`] #[inline] pub fn sealed_block(&self) -> &SealedBlock {