Skip to content
Snippets Groups Projects
Commit d1830a78 authored by Éloïs's avatar Éloïs
Browse files

feat(indexer): add extension .bin.gz to blocks chunks files

parent 5ae008dc
No related branches found
No related tags found
No related merge requests found
Pipeline #12472 passed
...@@ -19,6 +19,8 @@ use flate2::write::ZlibEncoder; ...@@ -19,6 +19,8 @@ use flate2::write::ZlibEncoder;
use flate2::Compression; use flate2::Compression;
const CHUNK_SIZE: u32 = 4_096; const CHUNK_SIZE: u32 = 4_096;
const CHUNK_FILE_PREFIX: &str = "_";
const CHUNK_FILE_EXT: &str = ".bin.gz";
pub fn apply_block_blocks_chunk<B: Backend>( pub fn apply_block_blocks_chunk<B: Backend>(
block: &DubpBlockV10, block: &DubpBlockV10,
...@@ -60,7 +62,10 @@ fn read_and_remove_compressed_chunk( ...@@ -60,7 +62,10 @@ fn read_and_remove_compressed_chunk(
chunk_index: u32, chunk_index: u32,
chunks_folder_path: &Path, chunks_folder_path: &Path,
) -> std::io::Result<Option<Vec<u8>>> { ) -> std::io::Result<Option<Vec<u8>>> {
let file_path = chunks_folder_path.join(format!("_{}", chunk_index)); let file_path = chunks_folder_path.join(format!(
"{}{}{}",
CHUNK_FILE_PREFIX, chunk_index, CHUNK_FILE_EXT
));
if !file_path.exists() { if !file_path.exists() {
return Ok(None); return Ok(None);
} }
...@@ -86,7 +91,10 @@ fn write_and_compress_chunk_in_file( ...@@ -86,7 +91,10 @@ fn write_and_compress_chunk_in_file(
if !chunks_folder_path.exists() { if !chunks_folder_path.exists() {
std::fs::create_dir(chunks_folder_path)?; std::fs::create_dir(chunks_folder_path)?;
} }
let file = std::fs::File::create(chunks_folder_path.join(format!("_{}", chunk_index)))?; let file = std::fs::File::create(chunks_folder_path.join(format!(
"{}{}{}",
CHUNK_FILE_PREFIX, chunk_index, CHUNK_FILE_EXT
)))?;
let mut e = ZlibEncoder::new(file, Compression::new(3)); let mut e = ZlibEncoder::new(file, Compression::new(3));
e.write_all(chunk)?; e.write_all(chunk)?;
e.finish()?; e.finish()?;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment