seal: Refactor ext_gas_price (#6478)

* seal: Refactor ext_gas_price

* Remove seals dependency on pallet_transaction_payment
* Add weight as an argument to ext_gas_price

* Fixed documentation nits from review

* Do not use unchecked math even in test code
This commit is contained in:
Alexander Theißen
2020-06-24 12:52:49 +02:00
committed by GitHub
parent f36b78570f
commit a3a42f599a
9 changed files with 51 additions and 51 deletions
@@ -696,12 +696,14 @@ define_env!(Env, <E: Ext>,
Ok(())
},
// Stores the gas price for the current transaction into the scratch buffer.
// Stores the price for the specified amount of gas in scratch buffer.
//
// The data is encoded as T::Balance. The current contents of the scratch buffer are overwritten.
ext_gas_price(ctx) => {
// It is recommended to avoid specifying very small values for `gas` as the prices for a single
// gas can be smaller than one.
ext_gas_price(ctx, gas: u64) => {
ctx.scratch_buf.clear();
ctx.ext.get_weight_price().encode_to(&mut ctx.scratch_buf);
ctx.ext.get_weight_price(gas).encode_to(&mut ctx.scratch_buf);
Ok(())
},