Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 11 additions & 12 deletions client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<B, Block, C, A> ProposerFactory<A, B, C>
info!("🙌 Starting consensus session on top of parent {:?}", parent_hash);

let proposer = Proposer {
inner: Arc::new(ProposerInner {
inner: ProposerInner {
client: self.client.clone(),
parent_hash,
parent_id: id,
Expand All @@ -100,7 +100,7 @@ impl<B, Block, C, A> ProposerFactory<A, B, C>
now,
metrics: self.metrics.clone(),
_phantom: PhantomData,
}),
},
};

proposer
Expand Down Expand Up @@ -132,7 +132,7 @@ impl<A, B, Block, C> sp_consensus::Environment<Block> for

/// The proposer logic.
pub struct Proposer<B, Block: BlockT, C, A: TransactionPool> {
inner: Arc<ProposerInner<B, Block, C, A>>,
inner: ProposerInner<B, Block, C, A>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove ProposerInner now and put its fields here right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

}

/// Proposer inner, to wrap parameters under Arc.
Expand Down Expand Up @@ -165,17 +165,16 @@ impl<A, B, Block, C> sp_consensus::Proposer<Block> for
type Error = sp_blockchain::Error;

fn propose(
&mut self,
self,
inherent_data: InherentData,
inherent_digests: DigestFor<Block>,
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.inner.now)() + max_duration - max_duration / 3;
self.inner.propose_with(inherent_data, inherent_digests, deadline, record_proof)
})
}
}
Expand All @@ -191,7 +190,7 @@ impl<A, B, Block, C> ProposerInner<B, Block, C, A>
+ BlockBuilderApi<Block, Error = sp_blockchain::Error>,
{
fn propose_with(
&self,
self,
inherent_data: InherentData,
inherent_digests: DigestFor<Block>,
deadline: time::Instant,
Expand Down Expand Up @@ -399,7 +398,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();
Expand Down Expand Up @@ -440,7 +439,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();
Expand Down Expand Up @@ -489,7 +488,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()),
);
Expand Down Expand Up @@ -560,7 +559,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()),
);
Expand Down
2 changes: 1 addition & 1 deletion client/basic-authorship/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ mod tests {
type Proposal = future::Ready<Result<Proposal<TestBlock, Self::Transaction>, Error>>;

fn propose(
&mut self,
self,
_: InherentData,
digests: DigestFor<TestBlock>,
_: Duration,
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Proposer<TestBlock> for DummyProposer {
type Proposal = future::Ready<Result<Proposal<TestBlock, Self::Transaction>, Error>>;

fn propose(
&mut self,
mut self,
_: InherentData,
pre_digests: DigestFor<TestBlock>,
_: Duration,
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/manual-seal/src/seal_new_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub async fn seal_new_block<B, SC, HB, E, T, P>(
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();
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/pow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ fn mine_loop<B: BlockT, C, Algorithm, E, SO, S, CAW>(
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
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/slots/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
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,
Expand Down
2 changes: 1 addition & 1 deletion primitives/consensus/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub trait Proposer<B: BlockT> {
///
/// Returns a future that resolves to a [`Proposal`] or to [`Error`].
fn propose(
&mut self,
self,
inherent_data: InherentData,
inherent_digests: DigestFor<B>,
max_duration: Duration,
Expand Down