@@ -8,9 +8,13 @@ use std::{
8
8
collections:: { BTreeMap , HashMap } ,
9
9
} ;
10
10
11
- /// Outcome of an account info after block execution. Post-6780, accounts
12
- /// cannot be destroyed, only created or modified. In either case, the new and
13
- /// old states are contained in this object.
11
+ /// Outcome of an account info after block execution.
12
+ ///
13
+ /// Post-6780, accounts cannot be destroyed, only created or modified. In
14
+ /// either case, the new and old states are contained in this object.
15
+ ///
16
+ /// In general, this should not be instantiated directly. Instead, use the
17
+ /// [`BundleStateIndex`] to index a [`BundleState`].
14
18
#[ derive( Debug , Clone , PartialEq , Eq ) ]
15
19
pub enum InfoOutcome < ' a > {
16
20
/// Account was created after block execution.
@@ -69,14 +73,18 @@ impl<'a> From<&'a BundleAccount> for InfoOutcome<'a> {
69
73
}
70
74
}
71
75
72
- /// Contains the diff of an account after block execution. This includes the
73
- /// account info and the storage diff. This type ensures that the storage
74
- /// updates are sorted by slot.
76
+ /// Contains the diff of an account after block execution.
77
+ ///
78
+ /// This includes the account info and the storage diff. This type ensures that
79
+ /// the storage updates are sorted by slot.
75
80
///
76
81
/// Reverting this means:
77
82
/// - Write the original value for the account info (deleting the account if it
78
83
/// was created)
79
84
/// - Write the original value for each storage slot
85
+ ///
86
+ /// In general, this should not be instantiated directly. Instead, use the
87
+ /// [`BundleStateIndex`] to index a [`BundleState`].
80
88
#[ derive( Debug , Clone , PartialEq , Eq ) ]
81
89
pub struct AcctDiff < ' a > {
82
90
/// Outcome of an account info after block execution.
@@ -132,6 +140,19 @@ impl From<AcctDiff<'_>> for BundleAccount {
132
140
/// Reverting this type means reverting
133
141
/// - Reverting each account state
134
142
/// - Deleting each new contract
143
+ ///
144
+ /// ```
145
+ /// # use revm::db::BundleState;
146
+ /// # use trevm::journal::{BundleStateIndex, JournalEncode, JournalDecode, JournalDecodeError};
147
+ /// # fn make_index(bundle_state: &BundleState) -> Result<(), JournalDecodeError> {
148
+ /// let index = BundleStateIndex::from(bundle_state);
149
+ /// let serialized_index = index.encoded();
150
+ /// let decoded = BundleStateIndex::decode(&mut serialized_index.as_slice())?;
151
+ /// assert_eq!(index, decoded);
152
+ /// # Ok(())
153
+ /// # }
154
+ /// ```
155
+ ///
135
156
#[ derive( Debug , Clone , Default , PartialEq , Eq ) ]
136
157
pub struct BundleStateIndex < ' a > {
137
158
/// The state index contains the account and storage diffs for a single
0 commit comments