@@ -11,7 +11,7 @@ sha256t_tag! {
1111/// added and removed the equivalent amount of times, the accumulator is zero. In the context of
1212/// bitcoin, this is used to add and remove hashes of [`OutPoint`] data.
1313#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , std:: hash:: Hash ) ]
14- pub struct Accumulator {
14+ pub struct Aggregate {
1515 high : u128 ,
1616 low : u128 ,
1717}
@@ -36,14 +36,14 @@ fn split_in_half(a: [u8; 32]) -> ([u8; 16], [u8; 16]) {
3636
3737/// Update an accumulator by adding or spending a pre-hashed outpoint
3838#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
39- pub enum AccumulatorUpdate {
39+ pub enum AggregateUpdate {
4040 Add ( [ u8 ; 32 ] ) ,
4141 Spent ( [ u8 ; 32 ] ) ,
4242}
4343
44- impl Accumulator {
44+ impl Aggregate {
4545 /// The zero accumulator
46- pub const ZERO : Accumulator = Accumulator { high : 0 , low : 0 } ;
46+ pub const ZERO : Aggregate = Aggregate { high : 0 , low : 0 } ;
4747
4848 /// Build a new accumulator.
4949 pub const fn new ( ) -> Self {
@@ -66,10 +66,10 @@ impl Accumulator {
6666 }
6767
6868 /// Update the accumulator
69- pub fn update ( & mut self , update : AccumulatorUpdate ) {
69+ pub fn update ( & mut self , update : AggregateUpdate ) {
7070 match update {
71- AccumulatorUpdate :: Add ( added) => self . add_hashed_outpoint ( added) ,
72- AccumulatorUpdate :: Spent ( spent) => self . spend_hashed_outpoint ( spent) ,
71+ AggregateUpdate :: Add ( added) => self . add_hashed_outpoint ( added) ,
72+ AggregateUpdate :: Spent ( spent) => self . spend_hashed_outpoint ( spent) ,
7373 }
7474 }
7575
@@ -101,7 +101,7 @@ impl Accumulator {
101101 }
102102}
103103
104- impl Default for Accumulator {
104+ impl Default for Aggregate {
105105 fn default ( ) -> Self {
106106 Self :: ZERO
107107 }
@@ -218,7 +218,7 @@ mod tests {
218218
219219 #[ test]
220220 fn test_accumulator_is_zero ( ) {
221- let mut acc = Accumulator :: default ( ) ;
221+ let mut acc = Aggregate :: default ( ) ;
222222 let [ outpoint_one, outpoint_two, outpoint_three, outpoint_four, outpoint_five] =
223223 make_five_outpoint ( ) ;
224224 // Add the members
@@ -241,10 +241,10 @@ mod tests {
241241 fn test_same_state ( ) {
242242 let [ outpoint_one, outpoint_two, outpoint_three, outpoint_four, outpoint_five] =
243243 make_five_outpoint ( ) ;
244- let mut acc_ref = Accumulator :: default ( ) ;
244+ let mut acc_ref = Aggregate :: default ( ) ;
245245 acc_ref. add ( outpoint_two) ;
246246 acc_ref. add ( outpoint_four) ;
247- let mut acc_cmp = Accumulator :: default ( ) ;
247+ let mut acc_cmp = Aggregate :: default ( ) ;
248248 acc_cmp. add ( outpoint_one) ;
249249 acc_cmp. add ( outpoint_two) ;
250250 acc_cmp. add ( outpoint_three) ;
@@ -266,7 +266,7 @@ mod tests {
266266 let hash_three = hash_outpoint ( outpoint_three) ;
267267 let hash_four = hash_outpoint ( outpoint_four) ;
268268 let hash_five = hash_outpoint ( outpoint_five) ;
269- let mut acc = Accumulator :: default ( ) ;
269+ let mut acc = Aggregate :: default ( ) ;
270270 acc. add_hashed_outpoint ( hash_five) ;
271271 acc. add_hashed_outpoint ( hash_four) ;
272272 acc. add_hashed_outpoint ( hash_one) ;
@@ -288,17 +288,17 @@ mod tests {
288288 let hash_three = hash_outpoint ( outpoint_three) ;
289289 let hash_four = hash_outpoint ( outpoint_four) ;
290290 let hash_five = hash_outpoint ( outpoint_five) ;
291- let mut acc = Accumulator :: default ( ) ;
292- acc. update ( AccumulatorUpdate :: Add ( hash_one) ) ;
293- acc. update ( AccumulatorUpdate :: Add ( hash_two) ) ;
294- acc. update ( AccumulatorUpdate :: Add ( hash_three) ) ;
295- acc. update ( AccumulatorUpdate :: Add ( hash_four) ) ;
296- acc. update ( AccumulatorUpdate :: Add ( hash_five) ) ;
297- acc. update ( AccumulatorUpdate :: Spent ( hash_five) ) ;
298- acc. update ( AccumulatorUpdate :: Spent ( hash_four) ) ;
299- acc. update ( AccumulatorUpdate :: Spent ( hash_three) ) ;
300- acc. update ( AccumulatorUpdate :: Spent ( hash_two) ) ;
301- acc. update ( AccumulatorUpdate :: Spent ( hash_one) ) ;
291+ let mut acc = Aggregate :: default ( ) ;
292+ acc. update ( AggregateUpdate :: Add ( hash_one) ) ;
293+ acc. update ( AggregateUpdate :: Add ( hash_two) ) ;
294+ acc. update ( AggregateUpdate :: Add ( hash_three) ) ;
295+ acc. update ( AggregateUpdate :: Add ( hash_four) ) ;
296+ acc. update ( AggregateUpdate :: Add ( hash_five) ) ;
297+ acc. update ( AggregateUpdate :: Spent ( hash_five) ) ;
298+ acc. update ( AggregateUpdate :: Spent ( hash_four) ) ;
299+ acc. update ( AggregateUpdate :: Spent ( hash_three) ) ;
300+ acc. update ( AggregateUpdate :: Spent ( hash_two) ) ;
301+ acc. update ( AggregateUpdate :: Spent ( hash_one) ) ;
302302 assert ! ( acc. is_zero( ) ) ;
303303 }
304304
0 commit comments