refactor(tvix/store): use update_hasher in blobwriter

Make use of the helper function here as well.

Change-Id: Ia0afd84eb3903bb897ee6aee884dc291f3e4371c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8258
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2023-03-11 20:24:07 +01:00 committed by clbot
parent 62ecfc7001
commit 2fe7192dbc

View file

@ -1,4 +1,4 @@
use crate::chunkservice::{upload_chunk, ChunkService};
use crate::chunkservice::{update_hasher, upload_chunk, ChunkService};
use crate::{proto, Error};
use rayon::prelude::*;
use tracing::instrument;
@ -59,12 +59,8 @@ impl<CS: ChunkService + std::marker::Sync> std::io::Write for BlobWriter<'_, CS>
// calculate input_buf.len(), we need to return that later.
let input_buf_len = input_buf.len();
// update calculate blob hash, and use rayon if data is > 128KiB.
if input_buf.len() > 128 * 1024 {
self.blob_hasher.update_rayon(input_buf);
} else {
self.blob_hasher.update(input_buf);
}
// update blob hash
update_hasher(&mut self.blob_hasher, input_buf);
// prepend buf with existing data (from self.buf)
let buf: Vec<u8> = {