mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
Allow modules to indicate full block. (#1687)
* Add transaction skipping. * Update runtime.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
use crate::{GasSpent, Module, Trait};
|
||||
use balances;
|
||||
use runtime_primitives::BLOCK_FULL;
|
||||
use runtime_primitives::traits::{As, CheckedMul, CheckedSub, Zero};
|
||||
use runtime_support::StorageValue;
|
||||
|
||||
@@ -206,7 +207,8 @@ pub fn buy_gas<T: Trait>(
|
||||
// This cannot underflow since `gas_spent` is never greater than `block_gas_limit`.
|
||||
let gas_available = <Module<T>>::block_gas_limit() - <Module<T>>::gas_spent();
|
||||
if gas_limit > gas_available {
|
||||
return Err("block gas limit is reached");
|
||||
// gas limit reached, revert the transaction and retry again in the future
|
||||
return Err(BLOCK_FULL);
|
||||
}
|
||||
|
||||
// Buy the specified amount of gas.
|
||||
|
||||
@@ -207,7 +207,10 @@ impl<
|
||||
let r = f.dispatch(s.into());
|
||||
<system::Module<System>>::note_applied_extrinsic(&r, encoded_len as u32);
|
||||
|
||||
r.map(|_| internal::ApplyOutcome::Success).or_else(|e| Ok(internal::ApplyOutcome::Fail(e)))
|
||||
r.map(|_| internal::ApplyOutcome::Success).or_else(|e| match e {
|
||||
primitives::BLOCK_FULL => Err(internal::ApplyError::FullBlock),
|
||||
e => Ok(internal::ApplyOutcome::Fail(e))
|
||||
})
|
||||
}
|
||||
|
||||
fn final_checks(header: &System::Header) {
|
||||
|
||||
@@ -56,8 +56,8 @@ mod double_map;
|
||||
pub use self::storage::{StorageVec, StorageList, StorageValue, StorageMap};
|
||||
pub use self::hashable::Hashable;
|
||||
pub use self::dispatch::{Parameter, Dispatchable, Callable, IsSubType};
|
||||
pub use self::double_map::StorageDoubleMap;
|
||||
pub use runtime_io::print;
|
||||
pub use double_map::StorageDoubleMap;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use srml_support_procedural::decl_storage;
|
||||
|
||||
Reference in New Issue
Block a user