Skip to content

Commit

Permalink
Remove unnecessary payer balance lookup in burn
Browse files Browse the repository at this point in the history
  • Loading branch information
maplant committed Nov 14, 2023
1 parent 0360679 commit e682511
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions iot_packet_verifier/src/burner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ where
mut self,
shutdown: triggered::Listener,
) -> Result<(), BurnError<P::Error, S::Error>> {
tracing::info!("starting burner");
tracing::info!("Starting burner");
let mut burn_timer = time::interval(self.burn_period);
burn_timer.set_missed_tick_behavior(MissedTickBehavior::Skip);

Expand All @@ -76,12 +76,12 @@ where
match self.burn().await {
Ok(()) => (),
Err(err) => {
tracing::error!("error whilst handling denylist tick: {err:?}");
tracing::error!("Error while attempting to burn: {err:?}");
}
}
}
}
tracing::info!("stopping burner");
tracing::info!("Stopping burner");
Ok(())
}

Expand Down Expand Up @@ -115,13 +115,10 @@ where

let mut balance_lock = self.balances.lock().await;
let payer_account = balance_lock.get_mut(&payer).unwrap();
payer_account.burned -= amount;
// Reset the balance of the payer:
payer_account.balance = self
.solana
.payer_balance(&payer)
.await
.map_err(BurnError::SolanaError)?;
// Reduce the pending burn amount and the payer's balance by the amount
// we've burned.
payer_account.burned = payer_account.burned.saturating_sub(amount);
payer_account.balance = payer_account.balance.saturating_sub(amount);

metrics::counter!("burned", amount, "payer" => payer.to_string());

Expand Down
4 changes: 2 additions & 2 deletions iot_packet_verifier/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl ManagedTask for Daemon {

impl Daemon {
pub async fn run(mut self, shutdown: triggered::Listener) -> Result<()> {
tracing::info!("starting daemon");
tracing::info!("Starting verifier daemon");
loop {
tokio::select! {
biased;
Expand All @@ -56,7 +56,7 @@ impl Daemon {

}
}
tracing::info!("stopping daemon");
tracing::info!("Stopping verifier daemon");
Ok(())
}

Expand Down

0 comments on commit e682511

Please sign in to comment.