mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-11 09:23:23 -04:00
refactor(crypto): Reduce the size of MaybeEncryptedRoomKey.
This patch reduces the size of `MaybeEncryptedRoomKey` from 336 bytes to 32 bytes.
This commit is contained in:
@@ -60,8 +60,10 @@ use crate::{
|
||||
|
||||
pub enum MaybeEncryptedRoomKey {
|
||||
Encrypted {
|
||||
used_session: Session,
|
||||
share_info: ShareInfo,
|
||||
// `Box` the session to reduce the size of `Encrypted`.
|
||||
used_session: Box<Session>,
|
||||
// `Box` the session to reduce the size of `Encrypted`.
|
||||
share_info: Box<ShareInfo>,
|
||||
message: Raw<AnyToDeviceEventContent>,
|
||||
},
|
||||
/// We could not encrypt a message to this device because there is no active
|
||||
@@ -832,12 +834,12 @@ impl DeviceData {
|
||||
|
||||
match self.encrypt(store, &event_type, content).await {
|
||||
Ok((session, encrypted)) => Ok(MaybeEncryptedRoomKey::Encrypted {
|
||||
share_info: ShareInfo::new_shared(
|
||||
share_info: Box::new(ShareInfo::new_shared(
|
||||
session.sender_key().to_owned(),
|
||||
message_index,
|
||||
self.olm_wedging_index,
|
||||
),
|
||||
used_session: session,
|
||||
)),
|
||||
used_session: Box::new(session),
|
||||
message: encrypted.cast(),
|
||||
}),
|
||||
|
||||
|
||||
@@ -310,14 +310,14 @@ impl GroupSessionManager {
|
||||
|
||||
match result.maybe_encrypted_room_key {
|
||||
MaybeEncryptedRoomKey::Encrypted { used_session, share_info, message } => {
|
||||
result_builder.on_successful_encryption(&result.device, used_session, message);
|
||||
result_builder.on_successful_encryption(&result.device, *used_session, message);
|
||||
|
||||
let user_id = result.device.user_id().to_owned();
|
||||
let device_id = result.device.device_id().to_owned();
|
||||
share_infos
|
||||
.entry(user_id)
|
||||
.or_insert_with(BTreeMap::new)
|
||||
.insert(device_id, share_info);
|
||||
.insert(device_id, *share_info);
|
||||
}
|
||||
MaybeEncryptedRoomKey::MissingSession => {
|
||||
result_builder.on_missing_session(result.device);
|
||||
|
||||
Reference in New Issue
Block a user