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

Use async_trait in sc-consensus-slots #8461

Merged
merged 2 commits into from
Mar 27, 2021
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use std::{
};

use futures::prelude::*;
use parking_lot::Mutex;
use log::{debug, trace};

use codec::{Encode, Decode, Codec};
Expand Down Expand Up @@ -272,7 +271,7 @@ pub fn build_aura_worker<P, B, C, PF, I, SO, BS, Error>(
{
AuraWorker {
client,
block_import: Arc::new(Mutex::new(block_import)),
block_import,
env: proposer_factory,
keystore,
sync_oracle,
Expand All @@ -286,7 +285,7 @@ pub fn build_aura_worker<P, B, C, PF, I, SO, BS, Error>(

struct AuraWorker<C, E, I, P, SO, BS> {
client: Arc<C>,
block_import: Arc<Mutex<I>>,
block_import: I,
env: E,
keystore: SyncCryptoStorePtr,
sync_oracle: SO,
Expand Down Expand Up @@ -326,8 +325,8 @@ where
"aura"
}

fn block_import(&self) -> Arc<Mutex<Self::BlockImport>> {
self.block_import.clone()
fn block_import(&mut self) -> &mut Self::BlockImport {
&mut self.block_import
}

fn epoch_data(
Expand Down Expand Up @@ -805,7 +804,7 @@ mod tests {

let worker = AuraWorker {
client: client.clone(),
block_import: Arc::new(Mutex::new(client)),
block_import: client,
env: environ,
keystore: keystore.into(),
sync_oracle: DummyOracle.clone(),
Expand Down Expand Up @@ -854,7 +853,7 @@ mod tests {

let mut worker = AuraWorker {
client: client.clone(),
block_import: Arc::new(Mutex::new(client.clone())),
block_import: client.clone(),
env: environ,
keystore: keystore.into(),
sync_oracle: DummyOracle.clone(),
Expand Down
10 changes: 5 additions & 5 deletions client/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ pub fn start_babe<B, C, SC, E, I, SO, CAW, BS, Error>(BabeParams {
+ Sync + 'static,
Error: std::error::Error + Send + From<ConsensusError> + From<I::Error> + 'static,
SO: SyncOracle + Send + Sync + Clone + 'static,
CAW: CanAuthorWith<B> + Send + 'static,
CAW: CanAuthorWith<B> + Send + Sync + 'static,
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + 'static,
{
const HANDLE_BUFFER_SIZE: usize = 1024;
Expand All @@ -448,7 +448,7 @@ pub fn start_babe<B, C, SC, E, I, SO, CAW, BS, Error>(BabeParams {

let worker = BabeSlotWorker {
client: client.clone(),
block_import: Arc::new(Mutex::new(block_import)),
block_import,
env,
sync_oracle: sync_oracle.clone(),
force_authoring,
Expand Down Expand Up @@ -605,7 +605,7 @@ type SlotNotificationSinks<B> = Arc<

struct BabeSlotWorker<B: BlockT, C, E, I, SO, BS> {
client: Arc<C>,
block_import: Arc<Mutex<I>>,
block_import: I,
env: E,
sync_oracle: SO,
force_authoring: bool,
Expand Down Expand Up @@ -647,8 +647,8 @@ where
"babe"
}

fn block_import(&self) -> Arc<Mutex<Self::BlockImport>> {
self.block_import.clone()
fn block_import(&mut self) -> &mut Self::BlockImport {
&mut self.block_import
}

fn epoch_data(
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/slots/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ sp-inherents = { version = "3.0.0", path = "../../../primitives/inherents" }
sp-timestamp = { version = "3.0.0", path = "../../../primitives/timestamp" }
futures = "0.3.9"
futures-timer = "3.0.1"
parking_lot = "0.11.1"
log = "0.4.11"
thiserror = "1.0.21"
async-trait = "0.1.42"

[dev-dependencies]
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
Loading