显示此包…
1 个不稳定版本
0.8.0 | 2021年4月4日 |
---|---|
0.0.0 |
|
#114 在 #tetcoin
47 次每月下载
用于 6 个包 (4 直接)
1MB
16K SLoC
区块创建逻辑的基本实现。
示例
// 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),
RecordProof::Yes,
);
// We wait until the proposition is performed.
let block = futures::executor::block_on(future).unwrap();
println!("Generated block: {:?}", block.block);
许可证: GPL-3.0-or-later WITH Classpath-exception-2.0
lib.rs
:
区块创建逻辑的基本实现。
示例
// The first step is to create a `ProposerFactory`.
let mut proposer_factory = ProposerFactory::new(
spawner,
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),
RecordProof::Yes,
);
// We wait until the proposition is performed.
let block = futures::executor::block_on(future).unwrap();
println!("Generated block: {:?}", block.block);
依赖
~31–48MB
~831K SLoC