We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a492073 commit f2cc3e7Copy full SHA for f2cc3e7
crates/interpreter/src/gas.rs
@@ -136,13 +136,13 @@ impl Gas {
136
/// Returns `false` if the gas limit is exceeded.
137
#[inline]
138
#[must_use = "prefer using `gas!` instead to return an out-of-gas error on failure"]
139
- pub fn record_cost(&mut self, cost: u64) -> bool {
140
- let (remaining, overflow) = self.remaining.overflowing_sub(cost);
141
- let success = !overflow;
142
- if success {
143
- self.remaining = remaining;
+ pub fn record_cost(&mut self, cost: u64) -> bool {
+ if let Some(new_remaining) = self.remaining.checked_sub(cost) {
+ self.remaining = new_remaining;
+ true
+ } else {
144
+ false // OO Gas
145
}
- success
146
147
148
/// Record memory expansion
0 commit comments