Skip to content

Commit 945b459

Browse files
committed
Gas Optimization Improvements
1 parent 2146cc9 commit 945b459

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • contracts/ai-valuation/src

contracts/ai-valuation/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,5 +958,19 @@ mod ai_valuation {
958958
assert!(engine.register_model(model.clone()).is_ok());
959959
assert_eq!(engine.get_model("test_model".to_string()), Some(model));
960960
}
961+
962+
fn track_gas(&self, operation: &str, start: u64) {
963+
let used = start.saturating_sub(self.env().gas_left());
964+
self.env().emit_event(GasUsage {
965+
operation: operation.to_string(),
966+
weight_used: used,
967+
});
968+
}
969+
#[ink(event)]
970+
pub struct GasUsage {
971+
#[ink(topic)]
972+
operation: String,
973+
weight_used: u64,
974+
}
961975
}
962976
}

0 commit comments

Comments
 (0)