@@ -48,6 +48,11 @@ impl<'a> BlockUpdate<'a> {
48
48
& self . journal
49
49
}
50
50
51
+ /// Decompose the block update into its parts.
52
+ pub fn into_parts ( self ) -> ( u64 , B256 , BundleStateIndex < ' a > ) {
53
+ ( self . height , self . prev_journal_hash , self . journal )
54
+ }
55
+
51
56
/// Serialize the block update.
52
57
pub fn serialized ( & self ) -> & [ u8 ] {
53
58
self . serialized . get_or_init ( || JournalEncode :: encoded ( self ) ) . as_ref ( )
@@ -74,10 +79,17 @@ impl JournalEncode for BlockUpdate<'_> {
74
79
impl JournalDecode for BlockUpdate < ' static > {
75
80
fn decode ( buf : & mut & [ u8 ] ) -> Result < Self , JournalDecodeError > {
76
81
let original = * buf;
82
+ let height = JournalDecode :: decode ( buf) ?;
83
+ let prev_journal_hash = JournalDecode :: decode ( buf) ?;
84
+ let journal = JournalDecode :: decode ( buf) ?;
85
+
86
+ let bytes_read = original. len ( ) - buf. len ( ) ;
87
+ let original = & original[ ..bytes_read] ;
88
+
77
89
Ok ( Self {
78
- height : JournalDecode :: decode ( buf ) ? ,
79
- prev_journal_hash : JournalDecode :: decode ( buf ) ? ,
80
- journal : JournalDecode :: decode ( buf ) ? ,
90
+ height,
91
+ prev_journal_hash,
92
+ journal,
81
93
serialized : OnceLock :: from ( Bytes :: copy_from_slice ( original) ) ,
82
94
hash : OnceLock :: from ( keccak256 ( original) ) ,
83
95
} )
0 commit comments