From 572ae6d9543a222032dc88e7b09aa17abdf1ad20 Mon Sep 17 00:00:00 2001 From: kaichaosun Date: Tue, 3 Feb 2026 13:21:50 +0800 Subject: [PATCH] chore: fix dead code --- conversations/src/context.rs | 10 ---------- conversations/src/conversation/common.rs | 3 --- conversations/src/crypto.rs | 5 ----- conversations/src/inbox/inbox.rs | 11 ++++------- conversations/src/lib.rs | 6 ++++-- conversations/src/types.rs | 2 +- 6 files changed, 9 insertions(+), 28 deletions(-) diff --git a/conversations/src/context.rs b/conversations/src/context.rs index 97f70c9..3aceeb9 100644 --- a/conversations/src/context.rs +++ b/conversations/src/context.rs @@ -23,7 +23,6 @@ pub struct Context { _identity: Rc, store: SessionRegistry, inbox: Inbox, - buf_size: usize, convo_handle_map: HashMap>, next_convo_handle: ConvoHandle, } @@ -36,20 +35,11 @@ impl Context { _identity: identity, store: SessionRegistry::new(), inbox, - buf_size: 0, convo_handle_map: HashMap::new(), next_convo_handle: INITIAL_CONVO_HANDLE, } } - pub fn buffer_size(&self) -> usize { - self.buf_size - } - - pub fn set_buffer_size(&mut self, size: usize) { - self.buf_size = size - } - pub fn create_private_convo( &mut self, remote_bundle: &Introduction, diff --git a/conversations/src/conversation/common.rs b/conversations/src/conversation/common.rs index 3bc698e..0b1d9ca 100644 --- a/conversations/src/conversation/common.rs +++ b/conversations/src/conversation/common.rs @@ -12,7 +12,6 @@ pub trait HasConversationId: Debug { fn id(&self) -> SessionId<'_>; } -#[allow(dead_code)] pub trait InboundSessionHandler: HasConversationId + Debug { fn handle_frame( &mut self, @@ -27,13 +26,11 @@ pub trait OutboundSession: HasConversationId + Debug { fn remote_id(&self) -> String; } -#[allow(dead_code)] pub struct SessionRegistry { sessions: HashMap, Box>, handlers: HashMap, Box>, } -#[allow(dead_code)] impl SessionRegistry { pub fn new() -> Self { Self { diff --git a/conversations/src/crypto.rs b/conversations/src/crypto.rs index ecf0d11..ff9531f 100644 --- a/conversations/src/crypto.rs +++ b/conversations/src/crypto.rs @@ -1,5 +1,3 @@ -pub use blake2::Digest; -use blake2::{Blake2b, digest}; use prost::bytes::Bytes; pub use x25519_dalek::{PublicKey, StaticSecret}; @@ -12,6 +10,3 @@ impl CopyBytes for PublicKey { Bytes::copy_from_slice(self.as_bytes()) } } - -#[allow(dead_code)] -pub type Blake2b128 = Blake2b; diff --git a/conversations/src/inbox/inbox.rs b/conversations/src/inbox/inbox.rs index 44c07d8..690878a 100644 --- a/conversations/src/inbox/inbox.rs +++ b/conversations/src/inbox/inbox.rs @@ -141,6 +141,7 @@ impl Inbox { payload: proto::EncryptedPayload, ) -> Result<(SecretKey, proto::InboxV1Frame), ChatError> { let handshake = Self::extract_payload(payload)?; + let payload_bytes = handshake.payload.clone(); let header = handshake .header .ok_or(ChatError::UnexpectedPayload("InboxV1Header".into()))?; @@ -166,8 +167,7 @@ impl Inbox { &initator_ephemeral, ); - // TODO: Decrypt Content - let frame = proto::InboxV1Frame::decode(handshake.payload)?; + let frame = Self::decrypt_frame(payload_bytes)?; Ok((seed_key, frame)) } @@ -183,12 +183,9 @@ impl Inbox { Ok(handshake) } - fn decrypt_frame( - enc_payload: proto::InboxHandshakeV1, - ) -> Result { - let frame_bytes = enc_payload.payload; + fn decrypt_frame(payload_bytes: prost::bytes::Bytes) -> Result { // TODO: decrypt payload - let frame = proto::InboxV1Frame::decode(frame_bytes)?; + let frame = proto::InboxV1Frame::decode(payload_bytes)?; Ok(frame) } diff --git a/conversations/src/lib.rs b/conversations/src/lib.rs index 91aab32..43ecfb6 100644 --- a/conversations/src/lib.rs +++ b/conversations/src/lib.rs @@ -1,15 +1,17 @@ mod api; mod context; -mod conversation; +pub mod conversation; mod crypto; mod errors; mod identity; -mod inbox; +pub mod inbox; mod proto; mod types; mod utils; pub use api::*; +pub use conversation::common::{HasConversationId, InboundSessionHandler, OutboundSession}; +pub use inbox::Inbox; #[cfg(test)] mod tests { diff --git a/conversations/src/types.rs b/conversations/src/types.rs index 254ab9e..8d12f40 100644 --- a/conversations/src/types.rs +++ b/conversations/src/types.rs @@ -19,7 +19,7 @@ pub struct ContentData { // Internal type Definitions // Used by Conversations to attach addresses to outbound encrypted payloads -pub(crate) struct AddressedEncryptedPayload { +pub struct AddressedEncryptedPayload { pub delivery_address: String, pub data: proto::EncryptedPayload, }