Allow modules to indicate full block. (#1687)

* Add transaction skipping.

* Update runtime.
This commit is contained in:
Tomasz Drwięga
2019-02-08 15:35:48 +01:00
committed by Gav Wood
parent 091e222d99
commit 83f9e1e720
7 changed files with 43 additions and 9 deletions
+3 -1
View File
@@ -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.