@@ -34,6 +34,9 @@ pub struct SenderFeeTracker {
3434 id_to_fee : HashMap < Address , u128 > ,
3535 total_fee : u128 ,
3636
37+ fees_requesting : u128 ,
38+ ids_requesting : HashSet < Address > ,
39+
3740 buffer_window_fee : HashMap < Address , ExpiringSum > ,
3841 buffer_window_duration : Duration ,
3942 // there are some allocations that we don't want it to be
@@ -120,6 +123,7 @@ impl SenderFeeTracker {
120123 self . id_to_fee
121124 . iter ( )
122125 . filter ( |( addr, _) | !self . blocked_addresses . contains ( * addr) )
126+ . filter ( |( addr, _) | !self . ids_requesting . contains ( * addr) )
123127 . filter ( |( addr, _) | {
124128 self . failed_ravs
125129 . get ( * addr)
@@ -171,6 +175,20 @@ impl SenderFeeTracker {
171175 acc + expiring. get_sum ( & self . buffer_window_duration )
172176 } )
173177 }
178+
179+ pub fn start_rav_request ( & mut self , allocation_id : Address ) {
180+ let current_fee = self . id_to_fee . entry ( allocation_id) . or_default ( ) ;
181+ self . ids_requesting . insert ( allocation_id) ;
182+ self . fees_requesting += * current_fee;
183+ }
184+
185+ /// Should be called before `update`
186+ pub fn finish_rav_request ( & mut self , allocation_id : Address ) {
187+ let current_fee = self . id_to_fee . entry ( allocation_id) . or_default ( ) ;
188+ self . fees_requesting -= * current_fee;
189+ self . ids_requesting . remove ( & allocation_id) ;
190+ }
191+
174192 pub fn failed_rav_backoff ( & mut self , allocation_id : Address ) {
175193 // backoff = max(100ms * 2 ^ retries, 60s)
176194 let failed_rav = self . failed_ravs . entry ( allocation_id) . or_default ( ) ;
0 commit comments