refactor(tvix/store): factor out hash update into function

We're using this in a bunch of places. Let's move it into a helper
function.

Change-Id: I118fba35f6d343704520ba37280e4ca52a61da44
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8251
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
Florian Klink 2023-03-10 23:24:23 +01:00 committed by clbot
parent 2dc93f8de2
commit b049b88d2d
4 changed files with 35 additions and 19 deletions

View file

@ -1,4 +1,7 @@
use crate::{chunkservice::upload_chunk, proto};
use crate::{
chunkservice::{update_hasher, upload_chunk},
proto,
};
use std::{
collections::HashMap,
fmt::Debug,
@ -138,12 +141,8 @@ fn process_entry<BS: BlobService, CS: ChunkService + std::marker::Sync, DS: Dire
let chunk_len = chunk.data.len() as u32;
// update calculate blob hash, and use rayon if data is > 128KiB.
if chunk_len > 128 * 1024 {
blob_hasher.update_rayon(&chunk.data);
} else {
blob_hasher.update(&chunk.data);
}
// update calculate blob hash
update_hasher(&mut blob_hasher, &chunk.data);
let chunk_digest = upload_chunk(chunk_service, chunk.data)?;