Skip to content

Commit 4414f53

Browse files
committed
refactor: use value in tracker instead of adding
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent f4fb366 commit 4414f53

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tap-agent/src/agent/sender_account.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,13 @@ impl Actor for SenderAccount {
745745
&state.sender.to_string(),
746746
&allocation_id.to_string(),
747747
])
748-
.add(value as f64);
748+
.set(
749+
state
750+
.sender_fee_tracker
751+
.get_total_fee_for_allocation(&allocation_id)
752+
.map(|fee| fee.value)
753+
.unwrap_or_default() as f64,
754+
);
749755
}
750756
ReceiptFees::RavRequestResponse(rav_result) => {
751757
state.finalize_rav_request(allocation_id, rav_result);

tap-agent/src/tracker/generic_tracker.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ where
105105
pub fn get_total_fee(&self) -> u128 {
106106
self.global.get_total_fee()
107107
}
108+
109+
pub fn get_total_fee_for_allocation(&self, allocation: &Address) -> Option<U> {
110+
self.id_to_fee.get(allocation).map(|fee| fee.get_stats())
111+
}
108112
}
109113

110114
impl GenericTracker<GlobalFeeTracker, SenderFeeStats, DurationInfo, UnaggregatedReceipts> {

0 commit comments

Comments
 (0)