Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions crates/storage/zstd-compressors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ pub static TRANSACTION_DICTIONARY: &[u8] = include_bytes!("../transaction_dictio
pub use locals::*;
#[cfg(feature = "std")]
mod locals {
use super::*;
use super::{
Compressor, Decompressor, ReusableDecompressor, RECEIPT_DICTIONARY, TRANSACTION_DICTIONARY,
};
use core::cell::RefCell;

// We use `thread_local` compressors and decompressors because dictionaries can be quite big,
Expand Down Expand Up @@ -58,26 +60,27 @@ mod locals {
}
}

/// Fn creates tx [`Compressor`]
/// Creates a transaction [`Compressor`] with the appropriate dictionary.
pub fn create_tx_compressor() -> Compressor<'static> {
Compressor::with_dictionary(0, RECEIPT_DICTIONARY).expect("Failed to instantiate tx compressor")
Compressor::with_dictionary(0, TRANSACTION_DICTIONARY)
.expect("Failed to instantiate tx compressor")
}

/// Fn creates tx [`Decompressor`]
/// Creates a transaction [`Decompressor`] with the appropriate dictionary.
pub fn create_tx_decompressor() -> ReusableDecompressor {
ReusableDecompressor::new(
Decompressor::with_dictionary(TRANSACTION_DICTIONARY)
.expect("Failed to instantiate tx decompressor"),
)
}

/// Fn creates receipt [`Compressor`]
/// Creates a receipt [`Compressor`] with the appropriate dictionary.
pub fn create_receipt_compressor() -> Compressor<'static> {
Compressor::with_dictionary(0, RECEIPT_DICTIONARY)
.expect("Failed to instantiate receipt compressor")
}

/// Fn creates receipt [`Decompressor`]
/// Creates a receipt [`Decompressor`] with the appropriate dictionary.
pub fn create_receipt_decompressor() -> ReusableDecompressor {
ReusableDecompressor::new(
Decompressor::with_dictionary(RECEIPT_DICTIONARY)
Expand Down