Add LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY
This commit is contained in:
		
				
					committed by
					
						![mergify[bot]](/avatar/e3df20cd7a67969c41a65f03bea54961?size=40) mergify[bot]
						mergify[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							67daa6f01e
						
					
				
				
					commit
					a018d78056
				
			| @@ -7,6 +7,14 @@ use std::{ | ||||
| }; | ||||
| use tokio::runtime; | ||||
|  | ||||
| // Delay uploading the largest confirmed root for this many slots.  This is done in an attempt to | ||||
| // ensure that the `CacheBlockTimeService` has had enough time to add the block time for the root | ||||
| // before it's uploaded to BigTable. | ||||
| // | ||||
| // A more direct connection between CacheBlockTimeService and BigTableUploadService would be | ||||
| // preferable... | ||||
| const LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY: usize = 100; | ||||
|  | ||||
| pub struct BigTableUploadService { | ||||
|     thread: JoinHandle<()>, | ||||
| } | ||||
| @@ -43,18 +51,19 @@ impl BigTableUploadService { | ||||
|         block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>, | ||||
|         exit: Arc<AtomicBool>, | ||||
|     ) { | ||||
|         let mut starting_slot = 0; | ||||
|         let mut start_slot = 0; | ||||
|         loop { | ||||
|             if exit.load(Ordering::Relaxed) { | ||||
|                 break; | ||||
|             } | ||||
|  | ||||
|             let largest_confirmed_root = block_commitment_cache | ||||
|             let end_slot = block_commitment_cache | ||||
|                 .read() | ||||
|                 .unwrap() | ||||
|                 .largest_confirmed_root(); | ||||
|                 .largest_confirmed_root() | ||||
|                 .saturating_sub(LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY as u64); | ||||
|  | ||||
|             if largest_confirmed_root == starting_slot { | ||||
|             if end_slot <= start_slot { | ||||
|                 std::thread::sleep(std::time::Duration::from_secs(1)); | ||||
|                 continue; | ||||
|             } | ||||
| @@ -62,14 +71,14 @@ impl BigTableUploadService { | ||||
|             let result = runtime.block_on(solana_ledger::bigtable_upload::upload_confirmed_blocks( | ||||
|                 blockstore.clone(), | ||||
|                 bigtable_ledger_storage.clone(), | ||||
|                 starting_slot, | ||||
|                 Some(largest_confirmed_root), | ||||
|                 start_slot, | ||||
|                 Some(end_slot), | ||||
|                 true, | ||||
|                 exit.clone(), | ||||
|             )); | ||||
|  | ||||
|             match result { | ||||
|                 Ok(()) => starting_slot = largest_confirmed_root, | ||||
|                 Ok(()) => start_slot = end_slot, | ||||
|                 Err(err) => { | ||||
|                     warn!("bigtable: upload_confirmed_blocks: {}", err); | ||||
|                     std::thread::sleep(std::time::Duration::from_secs(2)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user