@@ -6,7 +6,11 @@ use crate::{
66 CoinConfigGenerator ,
77 } ,
88 combined_database:: CombinedDatabase ,
9- database:: Database ,
9+ database:: {
10+ database_description:: off_chain:: OffChain ,
11+ Database ,
12+ } ,
13+ fuel_core_graphql_api:: storage:: transactions:: TransactionStatuses ,
1014 p2p:: Multiaddr ,
1115 service:: {
1216 Config ,
@@ -33,7 +37,6 @@ use fuel_core_poa::{
3337 Trigger ,
3438} ;
3539use fuel_core_storage:: {
36- tables:: Transactions ,
3740 transactional:: AtomicView ,
3841 StorageAsRef ,
3942} ;
@@ -59,7 +62,6 @@ use fuel_core_types::{
5962 services:: p2p:: GossipsubMessageAcceptance ,
6063} ;
6164use futures:: StreamExt ;
62- use itertools:: Itertools ;
6365use rand:: {
6466 rngs:: StdRng ,
6567 SeedableRng ,
@@ -491,24 +493,27 @@ impl Node {
491493
492494 /// Wait for the node to reach consistency with the given transactions.
493495 pub async fn consistency ( & mut self , txs : & HashMap < Bytes32 , Transaction > ) {
494- let Self { db, .. } = self ;
495- let mut blocks = self . node . shared . block_importer . block_stream ( ) ;
496- while !not_found_txs ( db, txs) . is_empty ( ) {
496+ let db = self . node . shared . database . off_chain ( ) ;
497+ loop {
498+ let not_found = not_found_txs ( db, txs) ;
499+
500+ if not_found. is_empty ( ) {
501+ break ;
502+ }
503+
504+ let tx_id = not_found[ 0 ] ;
505+ let mut wait_transaction =
506+ self . node . transaction_status_change ( tx_id) . unwrap ( ) ;
507+
497508 tokio:: select! {
498- result = blocks . next( ) => {
499- result. unwrap( ) ;
509+ result = wait_transaction . next( ) => {
510+ let _ = result. unwrap( ) ;
500511 }
501512 _ = self . node. await_shutdown( ) => {
502513 panic!( "Got a stop signal" )
503514 }
504515 }
505516 }
506-
507- let count = db
508- . all_transactions ( None , None )
509- . filter_ok ( |tx| tx. is_script ( ) )
510- . count ( ) ;
511- assert_eq ! ( count, txs. len( ) ) ;
512517 }
513518
514519 /// Wait for the node to reach consistency with the given transactions within 10 seconds.
@@ -570,13 +575,17 @@ impl Node {
570575}
571576
572577fn not_found_txs < ' iter > (
573- db : & ' iter Database ,
578+ db : & ' iter Database < OffChain > ,
574579 txs : & ' iter HashMap < Bytes32 , Transaction > ,
575580) -> Vec < TxId > {
576581 let mut not_found = vec ! [ ] ;
577582 txs. iter ( ) . for_each ( |( id, tx) | {
578583 assert_eq ! ( id, & tx. id( & Default :: default ( ) ) ) ;
579- if !db. storage :: < Transactions > ( ) . contains_key ( id) . unwrap ( ) {
584+ let found = db
585+ . storage :: < TransactionStatuses > ( )
586+ . contains_key ( id)
587+ . unwrap ( ) ;
588+ if !found {
580589 not_found. push ( * id) ;
581590 }
582591 } ) ;
0 commit comments