mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
compress everything
This commit is contained in:
parent
092b1e0d6c
commit
3a6319f2f6
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4652,6 +4652,7 @@ dependencies = [
|
|||||||
"crossbeam-channel 0.4.2",
|
"crossbeam-channel 0.4.2",
|
||||||
"futures 0.3.5",
|
"futures 0.3.5",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"lz4-compress",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -8,6 +8,7 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
lz4-compress = "0.1.1"
|
||||||
#serialisation
|
#serialisation
|
||||||
bincode = "1.2"
|
bincode = "1.2"
|
||||||
serde = { version = "1.0" }
|
serde = { version = "1.0" }
|
||||||
|
@ -637,4 +637,10 @@ impl BParticipant {
|
|||||||
a2b_close_stream_s.clone(),
|
a2b_close_stream_s.clone(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
async fn close_participant(&self) {
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
@ -182,9 +182,10 @@ impl TcpProtocol {
|
|||||||
bytes[15],
|
bytes[15],
|
||||||
]);
|
]);
|
||||||
let length = u16::from_le_bytes([bytes[16], bytes[17]]);
|
let length = u16::from_le_bytes([bytes[16], bytes[17]]);
|
||||||
let mut data = vec![0; length as usize];
|
let mut cdata = vec![0; length as usize];
|
||||||
throughput_cache.inc_by(length as i64);
|
throughput_cache.inc_by(length as i64);
|
||||||
Self::read_except_or_close(cid, &stream, &mut data, w2c_cid_frame_s).await;
|
Self::read_except_or_close(cid, &stream, &mut cdata, w2c_cid_frame_s).await;
|
||||||
|
let data = lz4_compress::decompress(&cdata).unwrap();
|
||||||
Frame::Data { mid, start, data }
|
Frame::Data { mid, start, data }
|
||||||
},
|
},
|
||||||
FRAME_RAW => {
|
FRAME_RAW => {
|
||||||
@ -347,6 +348,7 @@ impl TcpProtocol {
|
|||||||
},
|
},
|
||||||
Frame::Data { mid, start, data } => {
|
Frame::Data { mid, start, data } => {
|
||||||
throughput_cache.inc_by(data.len() as i64);
|
throughput_cache.inc_by(data.len() as i64);
|
||||||
|
let cdata = lz4_compress::compress(&data);
|
||||||
Self::write_or_close(&mut stream, &FRAME_DATA.to_be_bytes(), &mut c2w_frame_r)
|
Self::write_or_close(&mut stream, &FRAME_DATA.to_be_bytes(), &mut c2w_frame_r)
|
||||||
.await
|
.await
|
||||||
|| Self::write_or_close(&mut stream, &mid.to_le_bytes(), &mut c2w_frame_r)
|
|| Self::write_or_close(&mut stream, &mid.to_le_bytes(), &mut c2w_frame_r)
|
||||||
@ -355,11 +357,11 @@ impl TcpProtocol {
|
|||||||
.await
|
.await
|
||||||
|| Self::write_or_close(
|
|| Self::write_or_close(
|
||||||
&mut stream,
|
&mut stream,
|
||||||
&(data.len() as u16).to_le_bytes(),
|
&(cdata.len() as u16).to_le_bytes(),
|
||||||
&mut c2w_frame_r,
|
&mut c2w_frame_r,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|| Self::write_or_close(&mut stream, &data, &mut c2w_frame_r).await
|
|| Self::write_or_close(&mut stream, &cdata, &mut c2w_frame_r).await
|
||||||
},
|
},
|
||||||
Frame::Raw(data) => {
|
Frame::Raw(data) => {
|
||||||
Self::write_or_close(&mut stream, &FRAME_RAW.to_be_bytes(), &mut c2w_frame_r)
|
Self::write_or_close(&mut stream, &FRAME_RAW.to_be_bytes(), &mut c2w_frame_r)
|
||||||
|
@ -34,7 +34,7 @@ pub const PROMISES_COMPRESSED: Promises = 8;
|
|||||||
pub const PROMISES_ENCRYPTED: Promises = 16;
|
pub const PROMISES_ENCRYPTED: Promises = 16;
|
||||||
|
|
||||||
pub(crate) const VELOREN_MAGIC_NUMBER: [u8; 7] = [86, 69, 76, 79, 82, 69, 78]; //VELOREN
|
pub(crate) const VELOREN_MAGIC_NUMBER: [u8; 7] = [86, 69, 76, 79, 82, 69, 78]; //VELOREN
|
||||||
pub const VELOREN_NETWORK_VERSION: [u32; 3] = [0, 2, 0];
|
pub const VELOREN_NETWORK_VERSION: [u32; 3] = [0, 3, 0];
|
||||||
pub(crate) const STREAM_ID_OFFSET1: Sid = Sid::new(0);
|
pub(crate) const STREAM_ID_OFFSET1: Sid = Sid::new(0);
|
||||||
pub(crate) const STREAM_ID_OFFSET2: Sid = Sid::new(u64::MAX / 2);
|
pub(crate) const STREAM_ID_OFFSET2: Sid = Sid::new(u64::MAX / 2);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user