Files
pezkuwi-subxt/substrate/client/basic-authorship
Zeke Mostov 5ea4823dab Add prometheus metrics for block authorship (#10316)
* Add prom metric  to basic authorship

* Add proposer_block_proposal_time

* +nightly-2021-10-29 fmt

* Use saturating_duration_since, not elasped

* Update client/basic-authorship/src/basic_authorship.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/basic-authorship/src/basic_authorship.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* +nightly-2021-10-29 fmt

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2021-11-19 15:14:21 +00:00
..

Basic implementation of block-authoring logic.

Example

// 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(&BlockId::number(0)).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