From f11ec1ba8cbae9401035957dd7b7bcfc0e7c3799 Mon Sep 17 00:00:00 2001 From: cuteolaf <53915161+cuteolaf@users.noreply.github.com> Date: Mon, 6 Feb 2023 09:34:52 -0800 Subject: [PATCH] Fix: Off-chain-worker example (#13300) * fix: divider * update comment --- substrate/frame/examples/offchain-worker/src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/substrate/frame/examples/offchain-worker/src/lib.rs b/substrate/frame/examples/offchain-worker/src/lib.rs index 46ff7725e3b..203ea2f27ba 100644 --- a/substrate/frame/examples/offchain-worker/src/lib.rs +++ b/substrate/frame/examples/offchain-worker/src/lib.rs @@ -410,15 +410,14 @@ impl<T: Config> Pallet<T> { match res { // The value has been set correctly, which means we can safely send a transaction now. Ok(block_number) => { - // Depending if the block is even or odd we will send a `Signed` or `Unsigned` - // transaction. + // We will send different transactions based on a random number. // Note that this logic doesn't really guarantee that the transactions will be sent // in an alternating fashion (i.e. fairly distributed). Depending on the execution // order and lock acquisition, we may end up for instance sending two `Signed` // transactions in a row. If a strict order is desired, it's better to use // the storage entry for that. (for instance store both block number and a flag // indicating the type of next transaction to send). - let transaction_type = block_number % 3u32.into(); + let transaction_type = block_number % 4u32.into(); if transaction_type == Zero::zero() { TransactionType::Signed } else if transaction_type == T::BlockNumber::from(1u32) { -- GitLab