Drain the entire compute budget (bp #12478) (#12492)

* Drain the entire compute budget (#12478)


(cherry picked from commit d00453f747)

* fix conflict

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-09-25 23:22:19 +00:00
committed by GitHub
parent 99b513d905
commit b96e0e3d27
4 changed files with 7 additions and 4 deletions

View File

@@ -187,8 +187,9 @@ pub struct ThisComputeMeter {
}
impl ComputeMeter for ThisComputeMeter {
fn consume(&mut self, amount: u64) -> Result<(), InstructionError> {
let exceeded = self.remaining < amount;
self.remaining = self.remaining.saturating_sub(amount);
if self.remaining == 0 {
if exceeded {
return Err(InstructionError::ComputationalBudgetExceeded);
}
Ok(())