mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 16:07:57 +00:00
Clean up the basic-authorship crate (#3206)
* Switch consensus-common to new futures * Fix tests * More tests fixing * Make Proposer, OnSlot and SyncOracle mut * Make the Environment mut as well * Fix test * Fix Babe tests * Babe fixes * Fix CLI service tests * Fix Babe tests * Remove unnecessary trait bound * Inline the code of BlockBuilder and AuthoringApi * Remove warning lint * Bounds simplification * Imports simplification * Don't panic on bad generated block * Code style * Add doc example * Remove dependency on aura * Order dependencies alphabetically * Minor style
This commit is contained in:
committed by
DemiMarie-parity
parent
ba55d31d44
commit
9370a4a6b6
@@ -61,7 +61,7 @@ pub trait Environment<B: BlockT> {
|
||||
|
||||
/// Initialize the proposal logic on top of a specific header. Provide
|
||||
/// the authorities at that header.
|
||||
fn init(&self, parent_header: &B::Header)
|
||||
fn init(&mut self, parent_header: &B::Header)
|
||||
-> Result<Self::Proposer, Self::Error>;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ pub trait Proposer<B: BlockT> {
|
||||
type Create: Future<Output = Result<B, Self::Error>>;
|
||||
/// Create a proposal.
|
||||
fn propose(
|
||||
&self,
|
||||
&mut self,
|
||||
inherent_data: InherentData,
|
||||
inherent_digests: DigestFor<B>,
|
||||
max_duration: Duration,
|
||||
@@ -92,10 +92,10 @@ pub trait Proposer<B: BlockT> {
|
||||
pub trait SyncOracle {
|
||||
/// Whether the synchronization service is undergoing major sync.
|
||||
/// Returns true if so.
|
||||
fn is_major_syncing(&self) -> bool;
|
||||
fn is_major_syncing(&mut self) -> bool;
|
||||
/// Whether the synchronization service is offline.
|
||||
/// Returns true if so.
|
||||
fn is_offline(&self) -> bool;
|
||||
fn is_offline(&mut self) -> bool;
|
||||
}
|
||||
|
||||
/// A synchronization oracle for when there is no network.
|
||||
@@ -103,16 +103,18 @@ pub trait SyncOracle {
|
||||
pub struct NoNetwork;
|
||||
|
||||
impl SyncOracle for NoNetwork {
|
||||
fn is_major_syncing(&self) -> bool { false }
|
||||
fn is_offline(&self) -> bool { false }
|
||||
fn is_major_syncing(&mut self) -> bool { false }
|
||||
fn is_offline(&mut self) -> bool { false }
|
||||
}
|
||||
|
||||
impl<T: SyncOracle> SyncOracle for Arc<T> {
|
||||
fn is_major_syncing(&self) -> bool {
|
||||
T::is_major_syncing(&*self)
|
||||
impl<T> SyncOracle for Arc<T>
|
||||
where T: ?Sized, for<'r> &'r T: SyncOracle
|
||||
{
|
||||
fn is_major_syncing(&mut self) -> bool {
|
||||
<&T>::is_major_syncing(&mut &**self)
|
||||
}
|
||||
fn is_offline(&self) -> bool {
|
||||
T::is_offline(&*self)
|
||||
fn is_offline(&mut self) -> bool {
|
||||
<&T>::is_offline(&mut &**self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user