diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index 8985488427cee..5a38a74a40a64 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -91,16 +91,14 @@ impl ProposerFactory info!("🙌 Starting consensus session on top of parent {:?}", parent_hash); let proposer = Proposer { - inner: Arc::new(ProposerInner { - client: self.client.clone(), - parent_hash, - parent_id: id, - parent_number: *parent_header.number(), - transaction_pool: self.transaction_pool.clone(), - now, - metrics: self.metrics.clone(), - _phantom: PhantomData, - }), + client: self.client.clone(), + parent_hash, + parent_id: id, + parent_number: *parent_header.number(), + transaction_pool: self.transaction_pool.clone(), + now, + metrics: self.metrics.clone(), + _phantom: PhantomData, }; proposer @@ -132,11 +130,6 @@ impl sp_consensus::Environment for /// The proposer logic. pub struct Proposer { - inner: Arc>, -} - -/// Proposer inner, to wrap parameters under Arc. -struct ProposerInner { client: Arc, parent_hash: ::Hash, parent_id: BlockId, @@ -165,22 +158,21 @@ impl sp_consensus::Proposer for type Error = sp_blockchain::Error; fn propose( - &mut self, + self, inherent_data: InherentData, inherent_digests: DigestFor, max_duration: time::Duration, record_proof: RecordProof, ) -> Self::Proposal { - let inner = self.inner.clone(); tokio_executor::blocking::run(move || { // leave some time for evaluation and block finalization (33%) - let deadline = (inner.now)() + max_duration - max_duration / 3; - inner.propose_with(inherent_data, inherent_digests, deadline, record_proof) + let deadline = (self.now)() + max_duration - max_duration / 3; + self.propose_with(inherent_data, inherent_digests, deadline, record_proof) }) } } -impl ProposerInner +impl Proposer where A: TransactionPool, B: backend::Backend + Send + Sync + 'static, @@ -191,7 +183,7 @@ impl ProposerInner + BlockBuilderApi, { fn propose_with( - &self, + self, inherent_data: InherentData, inherent_digests: DigestFor, deadline: time::Instant, @@ -399,7 +391,7 @@ mod tests { let mut proposer_factory = ProposerFactory::new(client.clone(), txpool.clone(), None); let cell = Mutex::new((false, time::Instant::now())); - let mut proposer = proposer_factory.init_with_now( + let proposer = proposer_factory.init_with_now( &client.header(&BlockId::number(0)).unwrap().unwrap(), Box::new(move || { let mut value = cell.lock(); @@ -440,7 +432,7 @@ mod tests { let mut proposer_factory = ProposerFactory::new(client.clone(), txpool.clone(), None); let cell = Mutex::new((false, time::Instant::now())); - let mut proposer = proposer_factory.init_with_now( + let proposer = proposer_factory.init_with_now( &client.header(&BlockId::number(0)).unwrap().unwrap(), Box::new(move || { let mut value = cell.lock(); @@ -489,7 +481,7 @@ mod tests { let mut proposer_factory = ProposerFactory::new(client.clone(), txpool.clone(), None); - let mut proposer = proposer_factory.init_with_now( + let proposer = proposer_factory.init_with_now( &client.header(&block_id).unwrap().unwrap(), Box::new(move || time::Instant::now()), ); @@ -560,7 +552,7 @@ mod tests { expected_block_extrinsics, expected_pool_transactions, | { - let mut proposer = proposer_factory.init_with_now( + let proposer = proposer_factory.init_with_now( &client.header(&BlockId::number(number)).unwrap().unwrap(), Box::new(move || time::Instant::now()), ); diff --git a/client/basic-authorship/src/lib.rs b/client/basic-authorship/src/lib.rs index f5f2c089f656e..63020c0e68af7 100644 --- a/client/basic-authorship/src/lib.rs +++ b/client/basic-authorship/src/lib.rs @@ -38,7 +38,7 @@ //! ); //! //! // The proposer is created asynchronously. -//! let mut proposer = futures::executor::block_on(proposer).unwrap(); +//! let proposer = futures::executor::block_on(proposer).unwrap(); //! //! // This `Proposer` allows us to create a block proposition. //! // The proposer will grab transactions from the transaction pool, and put them into the block. diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index 06aa7db400e41..818bb563484be 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -904,7 +904,7 @@ mod tests { type Proposal = future::Ready, Error>>; fn propose( - &mut self, + self, _: InherentData, digests: DigestFor, _: Duration, diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 774cc5b7a4a41..ada1332295d46 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -159,7 +159,7 @@ impl Proposer for DummyProposer { type Proposal = future::Ready, Error>>; fn propose( - &mut self, + mut self, _: InherentData, pre_digests: DigestFor, _: Duration, diff --git a/client/consensus/manual-seal/src/seal_new_block.rs b/client/consensus/manual-seal/src/seal_new_block.rs index 88b58ef4cc2b3..a608c978e6edb 100644 --- a/client/consensus/manual-seal/src/seal_new_block.rs +++ b/client/consensus/manual-seal/src/seal_new_block.rs @@ -108,7 +108,7 @@ pub async fn seal_new_block( None => select_chain.best_chain()? }; - let mut proposer = env.init(&header) + let proposer = env.init(&header) .map_err(|err| Error::StringError(format!("{}", err))).await?; let id = inherent_data_provider.create_inherent_data()?; let inherents_len = id.len(); diff --git a/client/consensus/pow/src/lib.rs b/client/consensus/pow/src/lib.rs index 2628a11d3baea..24a8b63281208 100644 --- a/client/consensus/pow/src/lib.rs +++ b/client/consensus/pow/src/lib.rs @@ -610,7 +610,7 @@ fn mine_loop( continue 'outer } - let mut proposer = futures::executor::block_on(env.init(&best_header)) + let proposer = futures::executor::block_on(env.init(&best_header)) .map_err(|e| Error::Environment(format!("{:?}", e)))?; let inherent_data = inherent_data_providers diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index f58e52da4121f..bfa2747e21ebe 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -239,7 +239,7 @@ pub trait SimpleSlotWorker { let logs = self.pre_digest_data(slot_number, &claim); // deadline our production to approx. the end of the slot - let proposing = awaiting_proposer.and_then(move |mut proposer| proposer.propose( + let proposing = awaiting_proposer.and_then(move |proposer| proposer.propose( slot_info.inherent_data, sp_runtime::generic::Digest { logs, diff --git a/primitives/consensus/common/src/lib.rs b/primitives/consensus/common/src/lib.rs index fc56b2251607c..da23172783cdc 100644 --- a/primitives/consensus/common/src/lib.rs +++ b/primitives/consensus/common/src/lib.rs @@ -157,7 +157,7 @@ pub trait Proposer { /// /// Returns a future that resolves to a [`Proposal`] or to [`Error`]. fn propose( - &mut self, + self, inherent_data: InherentData, inherent_digests: DigestFor, max_duration: Duration,