Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Rename OffchainWorker internal method. #4267

Merged
merged 2 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ where

/// Start an offchain worker and generate extrinsics.
pub fn offchain_worker(n: System::BlockNumber) {
<AllModules as OffchainWorker<System::BlockNumber>>::generate_extrinsics(n)
<AllModules as OffchainWorker<System::BlockNumber>>::offchain_worker(n)
}
}

Expand Down
4 changes: 2 additions & 2 deletions frame/support/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ macro_rules! decl_module {
$crate::sp_runtime::traits::OffchainWorker<$trait_instance::BlockNumber>
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
{
fn generate_extrinsics(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* }
fn offchain_worker(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* }
}
};

Expand All @@ -1014,7 +1014,7 @@ macro_rules! decl_module {
$crate::sp_runtime::traits::OffchainWorker<$trait_instance::BlockNumber>
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
{
fn generate_extrinsics($param: $param_ty) { $( $impl )* }
fn offchain_worker($param: $param_ty) { $( $impl )* }
}
};

Expand Down
16 changes: 10 additions & 6 deletions primitives/sr-primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,18 +346,22 @@ pub trait OnInitialize<BlockNumber> {
/// Off-chain computation trait.
///
/// Implementing this trait on a module allows you to perform long-running tasks
/// that make validators generate extrinsics (either transactions or inherents)
/// with the results of those long-running computations.
/// that make (by default) validators generate transactions that feed results
/// of those long-running computations back on chain.
///
/// NOTE: This function runs off-chain, so it can access the block state,
/// but cannot preform any alterations.
/// but cannot preform any alterations. More specifically alterations are
/// not forbidden, but they are not persisted in any way after the worker
/// has finished.
#[impl_for_tuples(30)]
pub trait OffchainWorker<BlockNumber> {
/// This function is being called on every block.
/// This function is being called after every block import (when fully synced).
///
/// Implement this and use special `extern`s to generate transactions or inherents.
/// Implement this and use any of the `Offchain` `sp_io` set of APIs
/// to perform offchain computations, calls and submit transactions
/// with results to trigger any on-chain changes.
/// Any state alterations are lost and are not persisted.
fn generate_extrinsics(_n: BlockNumber) {}
fn offchain_worker(_n: BlockNumber) {}
}

/// Abstraction around hashing
Expand Down
4 changes: 2 additions & 2 deletions primitives/sr-version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ impl NativeVersion {
self.runtime_version.spec_name,
other.spec_name,
))
} else if (self.runtime_version.authoring_version != other.authoring_version
&& !self.can_author_with.contains(&other.authoring_version))
} else if self.runtime_version.authoring_version != other.authoring_version
&& !self.can_author_with.contains(&other.authoring_version)
{
Err(format!(
"`authoring_version` does not match `{version}` vs `{other_version}` and \
Expand Down