Crates.io | sc-basic-authorship |
lib.rs | sc-basic-authorship |
version | 0.45.0 |
source | src |
created_at | 2020-02-27 10:38:12.433987 |
updated_at | 2024-09-26 14:14:33.6133 |
description | Basic implementation of block-authoring logic. |
homepage | https://paritytech.github.io/polkadot-sdk/ |
repository | https://github.com/paritytech/polkadot-sdk.git |
max_upload_size | |
id | 213050 |
size | 46,121 |
Basic implementation of block-authoring logic.
// The first step is to create a `ProposerFactory`.
let mut proposer_factory = ProposerFactory::new(client.clone(), txpool.clone(), None);
// From this factory, we create a `Proposer`.
let proposer = proposer_factory.init(
&client.header(client.chain_info().genesis_hash).unwrap().unwrap(),
);
// The proposer is created asynchronously.
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.
let future = proposer.propose(
Default::default(),
Default::default(),
Duration::from_secs(2),
);
// We wait until the proposition is performed.
let block = futures::executor::block_on(future).unwrap();
println!("Generated block: {:?}", block.block);
License: GPL-3.0-or-later WITH Classpath-exception-2.0
Polkadot SDK stable2409