mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
Remove CanAuthorWith trait (#12213)
* Remove CanAuthorWith trait CanAuthotWith trait removed. Also all dependencies, parameters, type paramers were removed. This is related to removal of native runtime. * Remove commented code * Fix code formatting * trigger CI job * trigger CI job * trigger CI job * trigger CI job * trigger CI job * trigger CI job * trigger CI job
This commit is contained in:
committed by
GitHub
parent
6d0bb1a667
commit
214eb25f87
@@ -25,7 +25,6 @@ use std::{sync::Arc, time::Duration};
|
||||
|
||||
use futures::prelude::*;
|
||||
use sp_runtime::{
|
||||
generic::BlockId,
|
||||
traits::{Block as BlockT, HashFor},
|
||||
Digest,
|
||||
};
|
||||
@@ -268,61 +267,3 @@ where
|
||||
T::is_offline(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the current active native block authoring implementation can author with the runtime
|
||||
/// at the given block.
|
||||
pub trait CanAuthorWith<Block: BlockT> {
|
||||
/// See trait docs for more information.
|
||||
///
|
||||
/// # Return
|
||||
///
|
||||
/// - Returns `Ok(())` when authoring is supported.
|
||||
/// - Returns `Err(_)` when authoring is not supported.
|
||||
fn can_author_with(&self, at: &BlockId<Block>) -> Result<(), String>;
|
||||
}
|
||||
|
||||
/// Checks if the node can author blocks by using
|
||||
/// [`NativeVersion::can_author_with`](sp_version::NativeVersion::can_author_with).
|
||||
#[derive(Clone)]
|
||||
pub struct CanAuthorWithNativeVersion<T>(T);
|
||||
|
||||
impl<T> CanAuthorWithNativeVersion<T> {
|
||||
/// Creates a new instance of `Self`.
|
||||
pub fn new(inner: T) -> Self {
|
||||
Self(inner)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: sp_version::GetRuntimeVersionAt<Block> + sp_version::GetNativeVersion, Block: BlockT>
|
||||
CanAuthorWith<Block> for CanAuthorWithNativeVersion<T>
|
||||
{
|
||||
fn can_author_with(&self, at: &BlockId<Block>) -> Result<(), String> {
|
||||
match self.0.runtime_version(at) {
|
||||
Ok(version) => self.0.native_version().can_author_with(&version),
|
||||
Err(e) => Err(format!(
|
||||
"Failed to get runtime version at `{}` and will disable authoring. Error: {}",
|
||||
at, e,
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns always `true` for `can_author_with`. This is useful for tests.
|
||||
#[derive(Clone)]
|
||||
pub struct AlwaysCanAuthor;
|
||||
|
||||
impl<Block: BlockT> CanAuthorWith<Block> for AlwaysCanAuthor {
|
||||
fn can_author_with(&self, _: &BlockId<Block>) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Never can author.
|
||||
#[derive(Clone)]
|
||||
pub struct NeverCanAuthor;
|
||||
|
||||
impl<Block: BlockT> CanAuthorWith<Block> for NeverCanAuthor {
|
||||
fn can_author_with(&self, _: &BlockId<Block>) -> Result<(), String> {
|
||||
Err("Authoring is always disabled.".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user