@@ -437,28 +437,13 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
437
437
extrinsic : & [ u8 ] ,
438
438
) -> Result < StreamOfResults < TransactionStatus < T :: Hash > > , Error > {
439
439
// We care about new and finalized block hashes.
440
- enum SeenBlock < Ref > {
441
- New ( Ref ) ,
442
- Finalized ( Vec < Ref > ) ,
443
- }
444
440
enum SeenBlockMarker {
445
441
New ,
446
442
Finalized ,
447
443
}
448
444
449
- // First, subscribe to all new and finalized block refs.
450
- // - we subscribe to new refs so that when we see `BestChainBlockIncluded`, we
451
- // can try to return a block ref for the best block.
452
- // - we subscribe to finalized refs so that when we see `Finalized`, we can
453
- // guarantee that when we return here, the finalized block we report has been
454
- // reported from chainHead_follow already.
455
- let mut seen_blocks_sub = self . follow_handle . subscribe ( ) . events ( ) . filter_map ( |ev| {
456
- std:: future:: ready ( match ev {
457
- FollowEvent :: NewBlock ( ev) => Some ( SeenBlock :: New ( ev. block_hash ) ) ,
458
- FollowEvent :: Finalized ( ev) => Some ( SeenBlock :: Finalized ( ev. finalized_block_hashes ) ) ,
459
- _ => None ,
460
- } )
461
- } ) ;
445
+ // First, subscribe to new blocks.
446
+ let mut seen_blocks_sub = self . follow_handle . subscribe ( ) . events ( ) ;
462
447
463
448
// Then, submit the transaction.
464
449
let mut tx_progress = self
@@ -485,31 +470,36 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
485
470
// Make a note of new or finalized blocks that have come in since we started the TX.
486
471
if let Poll :: Ready ( Some ( seen_block) ) = seen_blocks_sub. poll_next_unpin ( cx) {
487
472
match seen_block {
488
- SeenBlock :: New ( block_ref) => {
473
+ FollowEvent :: NewBlock ( ev) => {
474
+ println ! ( "New block seen: {:?}" , ev. block_hash. hash( ) ) ;
489
475
// Optimization: once we have a `finalized_hash`, we only care about finalized
490
476
// block refs now and can avoid bothering to save new blocks.
491
477
if finalized_hash. is_none ( ) {
492
478
seen_blocks
493
- . insert ( block_ref . hash ( ) , ( SeenBlockMarker :: New , block_ref ) ) ;
479
+ . insert ( ev . block_hash . hash ( ) , ( SeenBlockMarker :: New , ev . block_hash ) ) ;
494
480
}
495
481
}
496
- SeenBlock :: Finalized ( block_refs) => {
497
- for block_ref in block_refs {
482
+ FollowEvent :: Finalized ( ev) => {
483
+ for block_ref in ev. finalized_block_hashes {
484
+ println ! ( "Finalized block seen: {:?}" , block_ref. hash( ) ) ;
498
485
seen_blocks. insert (
499
486
block_ref. hash ( ) ,
500
487
( SeenBlockMarker :: Finalized , block_ref) ,
501
488
) ;
502
489
}
503
- }
490
+ } ,
491
+ _ => { }
504
492
}
505
493
continue ;
506
494
}
507
495
508
496
// If we have a finalized hash, we are done looking for tx events and we are just waiting
509
497
// for a pinned block with a matching hash (which must appear eventually given it's finalized).
510
498
if let Some ( hash) = & finalized_hash {
499
+ println ! ( "Looking for finalized hash {hash:?}" ) ;
511
500
if let Some ( ( SeenBlockMarker :: Finalized , block_ref) ) = seen_blocks. remove ( hash)
512
501
{
502
+ println ! ( "Found finalized hash!" ) ;
513
503
// Found it! Hand back the event with a pinned block. We're done.
514
504
done = true ;
515
505
let ev = TransactionStatus :: InFinalizedBlock {
@@ -534,7 +524,7 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
534
524
Poll :: Ready ( Some ( Err ( e) ) ) => return Poll :: Ready ( Some ( Err ( e) ) ) ,
535
525
Poll :: Ready ( Some ( Ok ( ev) ) ) => ev,
536
526
} ;
537
-
527
+ println ! ( "TX Event seen: {ev:?}" ) ;
538
528
// When we get one, map it to the correct format (or for finalized ev, wait for the pinned block):
539
529
let ev = match ev {
540
530
rpc_methods:: TransactionStatus :: Finalized { block } => {
0 commit comments