-
Notifications
You must be signed in to change notification settings - Fork 246
Open
Labels
t:enhancementType: Feature, refactoring.Type: Feature, refactoring.
Description
Feature Request
Is your feature request related to a problem? Please describe.
In the current implementation, ckb-network only supports the Snappy compression method.
Lines 67 to 99 in 9f48908
| pub(crate) fn decompress(mut self) -> Result<Bytes, io::Error> { | |
| if self.inner.is_empty() { | |
| Err(io::ErrorKind::InvalidData.into()) | |
| } else if self.compress_flag() { | |
| match decompress_len(&self.inner[1..]) { | |
| Ok(decompressed_bytes_len) => { | |
| if decompressed_bytes_len > MAX_UNCOMPRESSED_LEN { | |
| debug!( | |
| "The limit for uncompressed bytes len is exceeded. limit: {}, len: {}", | |
| MAX_UNCOMPRESSED_LEN, decompressed_bytes_len | |
| ); | |
| Err(io::ErrorKind::InvalidData.into()) | |
| } else { | |
| let mut buf = vec![0; decompressed_bytes_len]; | |
| match SnapDecoder::new().decompress(&self.inner[1..], &mut buf) { | |
| Ok(_) => Ok(buf.into()), | |
| Err(e) => { | |
| debug!("snappy decompress error: {:?}", e); | |
| Err(io::ErrorKind::InvalidData.into()) | |
| } | |
| } | |
| } | |
| } | |
| Err(e) => { | |
| debug!("snappy decompress_len error: {:?}", e); | |
| Err(io::ErrorKind::InvalidData.into()) | |
| } | |
| } | |
| } else { | |
| let _ = self.inner.split_to(1); | |
| Ok(self.inner.freeze()) | |
| } | |
| } |
How about considering supporting other methods, such as lz4?
Metadata
Metadata
Assignees
Labels
t:enhancementType: Feature, refactoring.Type: Feature, refactoring.