diff --git a/storage/src/db/file_db/mapped_file.rs b/storage/src/db/file_db/mapped_file.rs index a6c535245..897c29f38 100644 --- a/storage/src/db/file_db/mapped_file.rs +++ b/storage/src/db/file_db/mapped_file.rs @@ -78,7 +78,7 @@ impl MappedFile { (self.ptr as *const u8).add(offset), buffer.as_mut_ptr(), buffer.len(), - ) + ); } /// Copies buffer to the mapped memory @@ -88,9 +88,9 @@ impl MappedFile { pub unsafe fn write_all_at(&self, offset: usize, buffer: &[u8]) { std::ptr::copy_nonoverlapping( buffer.as_ptr(), - (self.ptr as *mut u8).add(offset), + (self.ptr.cast::()).add(offset), buffer.len(), - ) + ); } } diff --git a/storage/src/db/file_db/mod.rs b/storage/src/db/file_db/mod.rs index 4be7821b5..fbff8234a 100644 --- a/storage/src/db/file_db/mod.rs +++ b/storage/src/db/file_db/mod.rs @@ -53,8 +53,8 @@ impl Seek for FileDb { } } -impl Into for FileDb { - fn into(self) -> File { - self.file +impl From for File { + fn from(val: FileDb) -> Self { + val.file } } diff --git a/storage/src/store/persistent_state/cell_writer.rs b/storage/src/store/persistent_state/cell_writer.rs index bb997e4db..036ba6a19 100644 --- a/storage/src/store/persistent_state/cell_writer.rs +++ b/storage/src/store/persistent_state/cell_writer.rs @@ -128,7 +128,7 @@ impl<'a> CellWriter<'a> { } pub fn remove(&self) -> Result<()> { - fs::remove_file(&self.base_path).context(format!( + fs::remove_file(self.base_path).context(format!( "Failed to remove persistent state file {:?}", self.base_path )) diff --git a/storage/src/store/persistent_state/mod.rs b/storage/src/store/persistent_state/mod.rs index e938bc70b..038d68e8c 100644 --- a/storage/src/store/persistent_state/mod.rs +++ b/storage/src/store/persistent_state/mod.rs @@ -49,11 +49,11 @@ impl PersistentStateStorage { block_id: &BlockId, root_hash: &HashBytes, ) -> Result<()> { - let block_id = block_id.clone(); + let block_id = *block_id; let root_hash = *root_hash; let db = self.db.clone(); let is_cancelled = Some(self.is_cancelled.clone()); - let base_path = self.get_state_file_path(&mc_block_id, &block_id); + let base_path = self.get_state_file_path(mc_block_id, &block_id); tokio::task::spawn_blocking(move || { let cell_writer = cell_writer::CellWriter::new(&db, &base_path); @@ -71,7 +71,7 @@ impl PersistentStateStorage { ); if let Err(e) = cell_writer.remove() { - tracing::error!(%block_id, "{e}") + tracing::error!(%block_id, "{e}"); } } } diff --git a/storage/src/store/shard_state/replace_transaction.rs b/storage/src/store/shard_state/replace_transaction.rs index 35d75ddf9..8ffde75e6 100644 --- a/storage/src/store/shard_state/replace_transaction.rs +++ b/storage/src/store/shard_state/replace_transaction.rs @@ -101,7 +101,8 @@ impl<'a> ShardStateReplaceTransaction<'a> { if chunk_size > 0 { tracing::debug!(chunk_size, "creating chunk"); - cells_file.write(&chunk_size.to_le_bytes())?; + let bytes = cells_file.write(&chunk_size.to_le_bytes())?; + tracing::trace!(bytes, "writing cells to file"); } if self.cells_read < header.cell_count { @@ -190,7 +191,7 @@ impl<'a> ShardStateReplaceTransaction<'a> { unsafe { hashes_file.read_exact_at(index as usize * HashesEntry::LEN, buffer) } } - self.finalize_cell(&mut ctx, cell_index as u32, cell)?; + ShardStateReplaceTransaction::finalize_cell(&mut ctx, cell_index as u32, cell)?; // SAFETY: `entries_buffer` is guaranteed to be in separate memory area unsafe { @@ -227,7 +228,7 @@ impl<'a> ShardStateReplaceTransaction<'a> { progress_bar.complete(); // Load stored shard state - let result = match self.db.shard_states.get(shard_state_key)? { + match self.db.shard_states.get(shard_state_key)? { Some(root) => { let cell_id = HashBytes::from_slice(&root[..32]); @@ -239,13 +240,10 @@ impl<'a> ShardStateReplaceTransaction<'a> { )?)) } None => Err(ReplaceTransactionError::NotFound.into()), - }; - - result + } } fn finalize_cell( - &self, ctx: &mut FinalizationContext<'_>, cell_index: u32, cell: RawCell<'_>, @@ -277,11 +275,7 @@ impl<'a> ShardStateReplaceTransaction<'a> { cell.descriptor.level_mask() } CellType::LibraryReference => LevelMask::new(0), - CellType::MerkleProof => { - is_merkle_cell = true; - children_mask.virtualize(1) - } - CellType::MerkleUpdate => { + CellType::MerkleProof | CellType::MerkleUpdate => { is_merkle_cell = true; children_mask.virtualize(1) } diff --git a/storage/src/utils/stored_value.rs b/storage/src/utils/stored_value.rs index 813edb106..deaea8198 100644 --- a/storage/src/utils/stored_value.rs +++ b/storage/src/utils/stored_value.rs @@ -165,7 +165,7 @@ impl StoredValue for BlockIdShort { } } -/// Writes BlockIdExt in little-endian format +/// Writes `BlockIdExt` in little-endian format pub fn write_block_id_le(block_id: &BlockId) -> [u8; 80] { let mut bytes = [0u8; 80]; bytes[..4].copy_from_slice(&block_id.shard.workchain().to_le_bytes()); @@ -176,7 +176,7 @@ pub fn write_block_id_le(block_id: &BlockId) -> [u8; 80] { bytes } -/// Reads BlockId in little-endian format +/// Reads `BlockId` in little-endian format pub fn read_block_id_le(data: &[u8]) -> Option { if data.len() < 80 { return None;