@@ -6,16 +6,12 @@ use alloy_primitives::{B256, map::B256Set};
6
6
/// Used by the [`crate::proof::ProofRetainer`] to determine which nodes may be ancestors of newly
7
7
/// added or removed leaves. This information allows for generation of more complete proofs which
8
8
/// include the nodes necessary for adding and removing leaves from the trie.
9
- ///
10
- /// Note: Currently only removed keys are tracked. Added keys tracking is not yet implemented.
11
9
#[ derive( Debug , Default , Clone ) ]
12
10
pub struct AddedRemovedKeys {
13
11
/// Keys which are known to be removed from the trie.
14
12
removed_keys : B256Set ,
15
- /// Keys which are known to be added to the trie.
13
+ /// Keys which are known to be newly added to the trie.
16
14
added_keys : B256Set ,
17
- /// Assume that all keys have been added.
18
- assume_added : bool ,
19
15
}
20
16
21
17
impl AsRef < Self > for AddedRemovedKeys {
@@ -25,14 +21,6 @@ impl AsRef<Self> for AddedRemovedKeys {
25
21
}
26
22
27
23
impl AddedRemovedKeys {
28
- /// Sets the `assume_added` flag, which can be used instead of `insert_added` if exact
29
- /// additions aren't known and you want to optimistically collect all proofs which _might_ be
30
- /// necessary.
31
- pub fn with_assume_added ( mut self , assume_added : bool ) -> Self {
32
- self . assume_added = assume_added;
33
- self
34
- }
35
-
36
24
/// Sets the key as being a removed key. This removes the key from the `added_keys` set if it
37
25
/// was previously inserted into it.
38
26
pub fn insert_removed ( & mut self , key : B256 ) {
@@ -59,16 +47,15 @@ impl AddedRemovedKeys {
59
47
60
48
/// Returns true if the given key path is marked as added.
61
49
pub fn is_added ( & self , path : & B256 ) -> bool {
62
- self . assume_added || self . added_keys . contains ( path)
50
+ self . added_keys . contains ( path)
63
51
}
64
52
65
53
/// Returns true if the given path prefix is the prefix of an added key.
66
54
pub fn is_prefix_added ( & self , prefix : & Nibbles ) -> bool {
67
- self . assume_added
68
- || self . added_keys . iter ( ) . any ( |key| {
69
- let key_nibbles = Nibbles :: unpack ( key) ;
70
- key_nibbles. starts_with ( prefix)
71
- } )
55
+ self . added_keys . iter ( ) . any ( |key| {
56
+ let key_nibbles = Nibbles :: unpack ( key) ;
57
+ key_nibbles. starts_with ( prefix)
58
+ } )
72
59
}
73
60
74
61
/// Returns a mask containing a bit set for each child of the branch which is a prefix of a
0 commit comments