Fix period of offchain transactions. (#4521)

* Fix period of offchain transactions.

* Calculate period dynamically.

* Convert to u64.
This commit is contained in:
Tomasz Drwięga
2020-01-03 21:39:46 +01:00
committed by Gavin Wood
parent f02e6d680a
commit 5986869390
2 changed files with 12 additions and 1 deletions
+5 -1
View File
@@ -500,7 +500,11 @@ impl frame_system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for
account: AccountId,
index: Index,
) -> Option<(Call, <UncheckedExtrinsic as traits::Extrinsic>::SignaturePayload)> {
let period = 1 << 8;
// take the biggest period possible.
let period = BlockHashCount::get()
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
let current_block = System::block_number().saturated_into::<u64>();
let tip = 0;
let extra: SignedExtra = (