mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-10 10:05:17 +00:00
Configre for force sync log from start block number
This commit is contained in:
parent
64a34e49f7
commit
553d9c9249
@ -32,6 +32,8 @@ pub struct LogSyncConfig {
|
||||
pub remove_finalized_block_interval_minutes: u64,
|
||||
// watch_loop (eth_getLogs) trigger interval
|
||||
pub watch_loop_wait_time_ms: u64,
|
||||
// force to sync log from start block number
|
||||
pub force_log_sync_from_start_block_number: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -58,6 +60,7 @@ impl LogSyncConfig {
|
||||
default_finalized_block_count: u64,
|
||||
remove_finalized_block_interval_minutes: u64,
|
||||
watch_loop_wait_time_ms: u64,
|
||||
force_log_sync_from_start_block_number: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
rpc_endpoint_url,
|
||||
@ -73,6 +76,7 @@ impl LogSyncConfig {
|
||||
default_finalized_block_count,
|
||||
remove_finalized_block_interval_minutes,
|
||||
watch_loop_wait_time_ms,
|
||||
force_log_sync_from_start_block_number,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,14 @@ impl LogSyncManager {
|
||||
block_hash_cache,
|
||||
};
|
||||
|
||||
let (mut start_block_number, mut start_block_hash) =
|
||||
let (mut start_block_number, mut start_block_hash) = if log_sync_manager
|
||||
.config
|
||||
.force_log_sync_from_start_block_number
|
||||
{
|
||||
let block_number = log_sync_manager.config.start_block_number;
|
||||
let block_hash = log_sync_manager.get_block(block_number.into()).await?.1;
|
||||
(block_number, block_hash)
|
||||
} else {
|
||||
match log_sync_manager.store.get_sync_progress()? {
|
||||
// No previous progress, so just use config.
|
||||
None => {
|
||||
@ -112,6 +119,7 @@ impl LogSyncManager {
|
||||
(block_number, block_hash)
|
||||
}
|
||||
Some((block_number, block_hash)) => (block_number, block_hash),
|
||||
}
|
||||
};
|
||||
|
||||
let (mut finalized_block_number, mut finalized_block_hash) =
|
||||
|
@ -156,6 +156,7 @@ impl ZgsConfig {
|
||||
self.default_finalized_block_count,
|
||||
self.remove_finalized_block_interval_minutes,
|
||||
self.watch_loop_wait_time_ms,
|
||||
self.force_log_sync_from_start_block_number,
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ build_config! {
|
||||
(blockchain_rpc_endpoint, (String), "http://127.0.0.1:8545".to_string())
|
||||
(log_contract_address, (String), "".to_string())
|
||||
(log_sync_start_block_number, (u64), 0)
|
||||
(force_log_sync_from_start_block_number, (bool), false)
|
||||
(confirmation_block_count, (u64), 12)
|
||||
(log_page_size, (u64), 999)
|
||||
(max_cache_data_size, (usize), 100 * 1024 * 1024) // 100 MB
|
||||
|
Loading…
Reference in New Issue
Block a user