@@ -12,7 +12,6 @@ use crate::{
12
12
} ,
13
13
fuel_core_graphql_api:: storage:: transactions:: TransactionStatuses ,
14
14
p2p:: Multiaddr ,
15
- schema:: tx:: types:: TransactionStatus ,
16
15
service:: {
17
16
Config ,
18
17
FuelService ,
@@ -40,7 +39,10 @@ use fuel_core_poa::{
40
39
Trigger ,
41
40
} ;
42
41
use fuel_core_storage:: {
43
- transactional:: AtomicView ,
42
+ transactional:: {
43
+ AtomicView ,
44
+ HistoricalView ,
45
+ } ,
44
46
StorageAsRef ,
45
47
} ;
46
48
use fuel_core_types:: {
@@ -571,6 +573,7 @@ impl Node {
571
573
/// Wait for the node to reach consistency with the given transactions.
572
574
pub async fn consistency ( & mut self , txs : & HashMap < Bytes32 , Transaction > ) {
573
575
let db = self . node . shared . database . off_chain ( ) ;
576
+ let mut latest_height = None ;
574
577
loop {
575
578
let not_found = not_found_txs ( db, txs) ;
576
579
@@ -587,9 +590,40 @@ impl Node {
587
590
result = wait_transaction. next( ) => {
588
591
let status = result. unwrap( ) . unwrap( ) ;
589
592
590
- if matches!( status, TransactionStatus :: Failure { .. } )
591
- || matches!( status, TransactionStatus :: Success { .. } ) {
592
- break
593
+ match ( latest_height, status. inclusion_height( ) ) {
594
+ ( Some ( ref mut latest_height) , Some ( inclusion_height) ) => {
595
+ if inclusion_height > * latest_height {
596
+ * latest_height = inclusion_height;
597
+ }
598
+ break ;
599
+ }
600
+ ( None , Some ( inclusion_height) ) => {
601
+ latest_height = Some ( inclusion_height) ;
602
+ break ;
603
+ }
604
+ _ => { }
605
+ }
606
+ }
607
+ _ = self . node. await_shutdown( ) => {
608
+ panic!( "Got a stop signal" )
609
+ }
610
+ }
611
+ }
612
+ }
613
+
614
+ if let Some ( latest_height) = latest_height {
615
+ let gas_price_database = self . node . shared . database . gas_price ( ) ;
616
+ let mut db_consistency_ticker =
617
+ tokio:: time:: interval ( std:: time:: Duration :: from_millis ( 50 ) ) ;
618
+ // let compression_database = self.node.shared.database.compression();
619
+ loop {
620
+ tokio:: select! {
621
+ _ = db_consistency_ticker. tick( ) => {
622
+ let gas_price_height = gas_price_database. latest_height( ) . unwrap( ) ;
623
+ // let compression_height = compression_database.latest_height().unwrap();
624
+
625
+ if gas_price_height >= latest_height {
626
+ break ;
593
627
}
594
628
}
595
629
_ = self . node. await_shutdown( ) => {
0 commit comments