mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 00:28:01 +00:00
Clean up the basic-authorship crate (#3206)
* Switch consensus-common to new futures * Fix tests * More tests fixing * Make Proposer, OnSlot and SyncOracle mut * Make the Environment mut as well * Fix test * Fix Babe tests * Babe fixes * Fix CLI service tests * Fix Babe tests * Remove unnecessary trait bound * Inline the code of BlockBuilder and AuthoringApi * Remove warning lint * Bounds simplification * Imports simplification * Don't panic on bad generated block * Code style * Add doc example * Remove dependency on aura * Order dependencies alphabetically * Minor style
This commit is contained in:
committed by
DemiMarie-parity
parent
ba55d31d44
commit
9370a4a6b6
@@ -15,9 +15,44 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Basic implementation of block-authoring logic.
|
||||
|
||||
#![warn(unused_extern_crates)]
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! ```
|
||||
//! # use substrate_basic_authorship::ProposerFactory;
|
||||
//! # use consensus_common::{Environment, Proposer};
|
||||
//! # use runtime_primitives::generic::BlockId;
|
||||
//! # use std::{sync::Arc, time::Duration};
|
||||
//! # use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring};
|
||||
//! # use transaction_pool::txpool::{self, Pool as TransactionPool};
|
||||
//! # let client = Arc::new(test_client::new());
|
||||
//! # let chain_api = transaction_pool::ChainApi::new(client.clone());
|
||||
//! # let txpool = Arc::new(TransactionPool::new(Default::default(), chain_api));
|
||||
//! // The first step is to create a `ProposerFactory`.
|
||||
//! let mut proposer_factory = ProposerFactory {
|
||||
//! client: client.clone(),
|
||||
//! transaction_pool: txpool.clone(),
|
||||
//! };
|
||||
//!
|
||||
//! // From this factory, we create a `Proposer`.
|
||||
//! let mut proposer = proposer_factory.init(
|
||||
//! &client.header(&BlockId::number(0)).unwrap().unwrap(),
|
||||
//! ).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);
|
||||
//! ```
|
||||
//!
|
||||
|
||||
mod basic_authorship;
|
||||
|
||||
pub use crate::basic_authorship::{ProposerFactory, BlockBuilder, AuthoringApi, Proposer};
|
||||
pub use crate::basic_authorship::{ProposerFactory, Proposer};
|
||||
|
||||
Reference in New Issue
Block a user