Adds fork-awareness and finalization notifications to transaction pool watchers. (#4740)

* adds finalization support to sc-transaction-pool using MaintainedTransactionPool for finalization events

* adds TransactionStatus::Retracted, notify watchers of retracted blocks, finalized now finalizes, transactions for current finalized -> last finalized block

* adds last_finalized to ChainApi, use generic BlockT for ChainEvent

* fix tests

* Apply suggestions from code review

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* tests

* fix tests, docs, lazily dedupe pruned hashes

* fix tests, Cargo.lock

* Apply suggestions from code review

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* remove tree_route, last_finalized from ChainApi, add block hash to Finalization and Retracted events

* prune finality watchers

* fix tests

* remove HeaderBackend bound from FullChainApi

* code style nits, terminate stream in finality_timeout

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
Seun Lanlege
2020-02-14 14:44:58 +01:00
committed by GitHub
parent b999911bcf
commit d3a3e288b6
18 changed files with 639 additions and 283 deletions
@@ -198,7 +198,7 @@ pub async fn run_instant_seal<B, CB, E, A, C, T>(
{
// instant-seal creates blocks as soon as transactions are imported
// into the transaction pool.
let seal_block_channel = pool.import_notification_stream()
let seal_block_channel = pool.validated_pool().import_notification_stream()
.map(|_| {
EngineCommand::SealNewBlock {
create_empty: false,
@@ -260,7 +260,7 @@ mod tests {
// this test checks that blocks are created as soon as transactions are imported into the pool.
let (sender, receiver) = futures::channel::oneshot::channel();
let mut sender = Arc::new(Some(sender));
let stream = pool.pool().import_notification_stream()
let stream = pool.pool().validated_pool().import_notification_stream()
.map(move |_| {
// we're only going to submit one tx so this fn will only be called once.
let mut_sender = Arc::get_mut(&mut sender).unwrap();
@@ -92,7 +92,7 @@ pub async fn seal_new_block<B, SC, CB, E, T, P>(
SC: SelectChain<B>,
{
let future = async {
if pool.status().ready == 0 && !create_empty {
if pool.validated_pool().status().ready == 0 && !create_empty {
return Err(Error::EmptyTransactionPool)
}