Add LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY
This commit is contained in:
parent
4ba43c29ce
commit
b64fb295a1
@ -7,6 +7,14 @@ use std::{
|
|||||||
};
|
};
|
||||||
use tokio::runtime;
|
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 {
|
pub struct BigTableUploadService {
|
||||||
thread: JoinHandle<()>,
|
thread: JoinHandle<()>,
|
||||||
}
|
}
|
||||||
@ -43,18 +51,19 @@ impl BigTableUploadService {
|
|||||||
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
|
||||||
exit: Arc<AtomicBool>,
|
exit: Arc<AtomicBool>,
|
||||||
) {
|
) {
|
||||||
let mut starting_slot = 0;
|
let mut start_slot = 0;
|
||||||
loop {
|
loop {
|
||||||
if exit.load(Ordering::Relaxed) {
|
if exit.load(Ordering::Relaxed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let max_confirmed_root = block_commitment_cache
|
let end_slot = block_commitment_cache
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.highest_confirmed_root();
|
.highest_confirmed_root()
|
||||||
|
.saturating_sub(LARGEST_CONFIRMED_ROOT_UPLOAD_DELAY as u64);
|
||||||
|
|
||||||
if max_confirmed_root == starting_slot {
|
if end_slot <= start_slot {
|
||||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -62,14 +71,14 @@ impl BigTableUploadService {
|
|||||||
let result = runtime.block_on(solana_ledger::bigtable_upload::upload_confirmed_blocks(
|
let result = runtime.block_on(solana_ledger::bigtable_upload::upload_confirmed_blocks(
|
||||||
blockstore.clone(),
|
blockstore.clone(),
|
||||||
bigtable_ledger_storage.clone(),
|
bigtable_ledger_storage.clone(),
|
||||||
starting_slot,
|
start_slot,
|
||||||
Some(max_confirmed_root),
|
Some(end_slot),
|
||||||
true,
|
true,
|
||||||
exit.clone(),
|
exit.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(()) => starting_slot = max_confirmed_root,
|
Ok(()) => start_slot = end_slot,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!("bigtable: upload_confirmed_blocks: {}", err);
|
warn!("bigtable: upload_confirmed_blocks: {}", err);
|
||||||
std::thread::sleep(std::time::Duration::from_secs(2));
|
std::thread::sleep(std::time::Duration::from_secs(2));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user