2 Commits

Author SHA1 Message Date
aab45b9c02 Merge pull request #23 from hl-archive-node/fix/handle-hl-node-termination
fix: Handle incomplete line when handling local-block-ingest
2025-07-19 21:47:07 -04:00
0ce6b818ad fix: Handle incomplete line when handling local-block-ingest 2025-07-19 17:04:01 -04:00

View File

@ -73,8 +73,23 @@ fn scan_hour_file(path: &Path, last_line: &mut usize, start_height: u64) -> Scan
continue; continue;
} }
let LocalBlockAndReceipts(_block_timestamp, parsed_block): LocalBlockAndReceipts = let (_block_timestamp, parsed_block) = match serde_json::from_str(&line) {
serde_json::from_str(&line).expect("Failed to parse local block and receipts"); Ok(LocalBlockAndReceipts(_block_timestamp, parsed_block)) => {
(_block_timestamp, parsed_block)
}
Err(_) => {
// Possible scenarios:
let is_last_line = line_idx == lines.len() - 1;
if is_last_line {
// 1. It's not written fully yet - in this case, just wait for the next line
break;
} else {
// 2. hl-node previously terminated while writing the lines
// In this case, try to skip this line
continue;
}
}
};
let height = match &parsed_block.block { let height = match &parsed_block.block {
EvmBlock::Reth115(b) => { EvmBlock::Reth115(b) => {