feat(indexer): add extension .bin.gz to blocks chunks files
This commit is contained in:
parent
5ae008dc02
commit
d1830a78a5
1 changed files with 10 additions and 2 deletions
|
@ -19,6 +19,8 @@ use flate2::write::ZlibEncoder;
|
|||
use flate2::Compression;
|
||||
|
||||
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>(
|
||||
block: &DubpBlockV10,
|
||||
|
@ -60,7 +62,10 @@ fn read_and_remove_compressed_chunk(
|
|||
chunk_index: u32,
|
||||
chunks_folder_path: &Path,
|
||||
) -> 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() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
@ -86,7 +91,10 @@ fn write_and_compress_chunk_in_file(
|
|||
if !chunks_folder_path.exists() {
|
||||
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));
|
||||
e.write_all(chunk)?;
|
||||
e.finish()?;
|
||||
|
|
Loading…
Add table
Reference in a new issue