mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-14 12:05:17 +00:00
Optimizing recover perf by reducing sync progress events (#244)
Some checks are pending
abi-consistent-check / build-and-compare (push) Waiting to run
code-coverage / unittest-cov (push) Waiting to run
rust / check (push) Waiting to run
rust / test (push) Waiting to run
rust / lints (push) Waiting to run
functional-test / test (push) Waiting to run
Some checks are pending
abi-consistent-check / build-and-compare (push) Waiting to run
code-coverage / unittest-cov (push) Waiting to run
rust / check (push) Waiting to run
rust / test (push) Waiting to run
rust / lints (push) Waiting to run
functional-test / test (push) Waiting to run
* Optimizing recover perf by reducing sync progress events * add log * add log
This commit is contained in:
parent
39efb721c5
commit
2947cb7ac6
@ -236,22 +236,29 @@ impl LogEntryFetcher {
|
|||||||
.filter;
|
.filter;
|
||||||
let mut stream = LogQuery::new(&provider, &filter, log_query_delay)
|
let mut stream = LogQuery::new(&provider, &filter, log_query_delay)
|
||||||
.with_page_size(log_page_size);
|
.with_page_size(log_page_size);
|
||||||
debug!(
|
info!(
|
||||||
"start_recover starts, start={} end={}",
|
"start_recover starts, start={} end={}",
|
||||||
start_block_number, end_block_number
|
start_block_number, end_block_number
|
||||||
);
|
);
|
||||||
|
let (mut block_hash_sent, mut block_number_sent) = (None, None);
|
||||||
while let Some(maybe_log) = stream.next().await {
|
while let Some(maybe_log) = stream.next().await {
|
||||||
match maybe_log {
|
match maybe_log {
|
||||||
Ok(log) => {
|
Ok(log) => {
|
||||||
let sync_progress =
|
let sync_progress =
|
||||||
if log.block_hash.is_some() && log.block_number.is_some() {
|
if log.block_hash.is_some() && log.block_number.is_some() {
|
||||||
let synced_block = LogFetchProgress::SyncedBlock((
|
if block_hash_sent != log.block_hash
|
||||||
log.block_number.unwrap().as_u64(),
|
|| block_number_sent != log.block_number
|
||||||
log.block_hash.unwrap(),
|
{
|
||||||
None,
|
let synced_block = LogFetchProgress::SyncedBlock((
|
||||||
));
|
log.block_number.unwrap().as_u64(),
|
||||||
progress = log.block_number.unwrap().as_u64();
|
log.block_hash.unwrap(),
|
||||||
Some(synced_block)
|
None,
|
||||||
|
));
|
||||||
|
progress = log.block_number.unwrap().as_u64();
|
||||||
|
Some(synced_block)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
@ -268,7 +275,12 @@ impl LogEntryFetcher {
|
|||||||
log.block_number.expect("block number exist").as_u64(),
|
log.block_number.expect("block number exist").as_u64(),
|
||||||
))
|
))
|
||||||
.and_then(|_| match sync_progress {
|
.and_then(|_| match sync_progress {
|
||||||
Some(b) => recover_tx.send(b),
|
Some(b) => {
|
||||||
|
recover_tx.send(b)?;
|
||||||
|
block_hash_sent = log.block_hash;
|
||||||
|
block_number_sent = log.block_number;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
None => Ok(()),
|
None => Ok(()),
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
@ -290,6 +302,8 @@ impl LogEntryFetcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info!("log recover end");
|
||||||
},
|
},
|
||||||
"log recover",
|
"log recover",
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user