Skip to content

Commit ea93965

Browse files
authored
Avoid redundantly serializing blob bytes. (#3763)
## Motivation BCS serializing a `Vec<u8>` (blob bytes) for storage is redundant. ## Proposal Store the bytes directly. ## Test Plan CI ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - Closes #3749. - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent b928691 commit ea93965

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

linera-storage/src/db_storage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl BatchExt for Batch {
223223
#[cfg(with_metrics)]
224224
WRITE_BLOB_COUNTER.with_label_values(&[]).inc();
225225
let blob_key = bcs::to_bytes(&BaseKey::Blob(blob.id()))?;
226-
self.put_key_value(blob_key.to_vec(), &blob.bytes())?;
226+
self.put_key_value_bytes(blob_key.to_vec(), blob.bytes().to_vec());
227227
Ok(())
228228
}
229229

@@ -526,7 +526,7 @@ where
526526

527527
async fn read_blob(&self, blob_id: BlobId) -> Result<Blob, ViewError> {
528528
let blob_key = bcs::to_bytes(&BaseKey::Blob(blob_id))?;
529-
let maybe_blob_bytes = self.store.read_value::<Vec<u8>>(&blob_key).await?;
529+
let maybe_blob_bytes = self.store.read_value_bytes(&blob_key).await?;
530530
#[cfg(with_metrics)]
531531
READ_BLOB_COUNTER.with_label_values(&[]).inc();
532532
let blob_bytes = maybe_blob_bytes.ok_or_else(|| ViewError::BlobsNotFound(vec![blob_id]))?;
@@ -541,7 +541,7 @@ where
541541
.iter()
542542
.map(|blob_id| bcs::to_bytes(&BaseKey::Blob(*blob_id)))
543543
.collect::<Result<Vec<_>, _>>()?;
544-
let maybe_blob_bytes = self.store.read_multi_values::<Vec<u8>>(blob_keys).await?;
544+
let maybe_blob_bytes = self.store.read_multi_values_bytes(blob_keys).await?;
545545
#[cfg(with_metrics)]
546546
READ_BLOB_COUNTER
547547
.with_label_values(&[])

0 commit comments

Comments
 (0)