Skip to main content

ProtocolEngine

Struct ProtocolEngine 

Source
pub struct ProtocolEngine {
    pub batch_depth: Cell<u32>,
    pub batch_persist_dirty: Cell<bool>,
    /* private fields */
}

Fields§

§batch_depth: Cell<u32>

While > 0, persist() only flips batch_persist_dirty instead of serializing+writing. AppCore wraps catch-up bursts and other multi-event entry points so an N-event burst issues one persist instead of N. The exclusive SQLite write under iOS DELETE-mode journaling can keep UI reads blocked on the connection mutex for hundreds of ms each — N of them stacked produced the multi-second foreground freeze.

§batch_persist_dirty: Cell<bool>

Implementations§

§

impl ProtocolEngine

pub fn load_or_create_for_local_device( storage: Arc<dyn StorageAdapter>, owner_pubkey: PublicKey, device_keys: &Keys, ) -> Result<Self>

pub fn debug_snapshot(&self) -> ProtocolEngineDebugSnapshot

pub fn session_manager_snapshot_for_test(&self) -> SessionManagerSnapshot

pub fn group_manager_snapshot_for_test(&self) -> GroupManagerSnapshot

pub fn is_known_local_owner_device(&self, device_pubkey: PublicKey) -> bool

pub fn owner_hint_for_device( &self, device_pubkey: PublicKey, ) -> Option<ProtocolDeviceOwnerHint>

pub fn has_pending_inbound_direct_events(&self) -> bool

pub fn has_pending_retry_work(&self) -> bool

pub fn has_pending_inbound_direct_event_id(&self, event_id: &str) -> bool

pub fn queued_owner_claim_targets(&self) -> Vec<String>

pub fn queued_protocol_backfill_effects( &self, now: NdrUnixSeconds, reason: &'static str, ) -> (Vec<String>, Vec<ProtocolEffect>)

pub fn queued_group_target_hexes(&self) -> Vec<String>

pub fn has_queued_invite_author(&self, author: PublicKey) -> bool

pub fn local_invite(&self) -> Option<Invite>

pub fn local_invite_response_pubkey(&self) -> Option<PublicKey>

pub fn pending_inbound_for_test(&self) -> Vec<ProtocolPendingInboundTestDebug>

pub fn known_message_author_pubkeys(&self) -> Vec<PublicKey>

pub fn message_author_pubkeys_filtered<F>( &self, accept_owner: F, ) -> Vec<PublicKey>
where F: Fn(PublicKey) -> bool,

Walks every session and returns its expected event-author pubkeys, but only for sessions whose peer owner passes the accept_owner predicate. The owner-aware variant lets the caller drop blocked / non-accepted peers from the subscription filter without losing the device-ephemeral keys that nostr actually filters on.

pub fn is_known_message_author(&self, author: PublicKey) -> bool

pub fn known_message_author_cache_build_count_for_test(&self) -> u64

pub fn pending_decrypted_deliveries_len_for_test(&self) -> usize

pub fn known_group_sender_event_pubkeys(&self) -> Vec<PublicKey>

pub fn is_known_group_sender_event_author(&self, author: PublicKey) -> bool

pub fn known_device_identity_pubkeys_for_owner( &self, owner_pubkey: PublicKey, ) -> Vec<PublicKey>

pub fn message_author_pubkeys_for_owner( &self, owner_pubkey: PublicKey, ) -> Vec<PublicKey>

pub fn session_manager_snapshot(&self) -> SessionManagerSnapshot

SessionManager::snapshot clones every user record + every device state — the runtime debug builder fans out per known user, so callers that hit multiple owners in one pass must share a single snapshot via the _with_snapshot helpers below instead of paying that clone cost per owner.

pub fn message_session_debug_snapshots_with_snapshot( snapshot: &SessionManagerSnapshot, owner_pubkey: PublicKey, ) -> Vec<ProtocolMessageSessionDebugSnapshot>

pub fn active_session_count_for_owner_with_snapshot( snapshot: &SessionManagerSnapshot, owner_pubkey: PublicKey, ) -> usize

pub fn active_session_count_for_owner(&self, owner_pubkey: PublicKey) -> usize

pub fn queued_message_diagnostics( &self, message_id: Option<&str>, ) -> Vec<String>

pub fn has_delivery_blocking_message_work(&self, message_id: &str) -> bool

§

impl ProtocolEngine

pub fn ingest_app_keys_snapshot( &mut self, owner_pubkey: PublicKey, app_keys: AppKeys, created_at: u64, ) -> Result<ProtocolRetryBatch>

pub fn observe_invite_event( &mut self, event: &Event, ) -> Result<ProtocolRetryBatch>

pub fn observe_invite_response_event( &mut self, event: &Event, ) -> Result<ProtocolRetryBatch>

pub fn accept_invite( &mut self, invite: &Invite, owner_pubkey_hint: Option<PublicKey>, ) -> Result<ProtocolAcceptInviteResult>

pub fn import_session_state( &mut self, peer_pubkey: PublicKey, device_id: Option<String>, state: SessionState, now: UnixSeconds, ) -> Result<ProtocolRetryBatch>

pub fn create_group( &mut self, name: String, member_owners: Vec<PublicKey>, now: UnixSeconds, ) -> Result<ProtocolGroupSendResult>

pub fn update_group_name( &mut self, group_id: &str, name: String, ) -> Result<ProtocolGroupSendResult>

pub fn update_group_picture( &mut self, group_id: &str, picture: Option<String>, ) -> Result<ProtocolGroupSendResult>

pub fn update_group_about( &mut self, group_id: &str, about: Option<String>, ) -> Result<ProtocolGroupSendResult>

pub fn add_group_members( &mut self, group_id: &str, members: Vec<PublicKey>, ) -> Result<ProtocolGroupSendResult>

pub fn remove_group_member( &mut self, group_id: &str, member: PublicKey, ) -> Result<ProtocolGroupSendResult>

pub fn set_group_admin( &mut self, group_id: &str, member: PublicKey, is_admin: bool, ) -> Result<ProtocolGroupSendResult>

pub fn send_group_payload( &mut self, group_id: &str, payload: Vec<u8>, inner_event_id: Option<String>, ) -> Result<ProtocolGroupSendResult>

pub fn send_direct_text( &mut self, peer_pubkey: PublicKey, chat_id: &str, text: &str, expires_at_secs: Option<u64>, now: UnixSeconds, ) -> Result<ProtocolDirectSendResult>

pub fn send_direct_unsigned_event( &mut self, peer_pubkey: PublicKey, chat_id: &str, rumor: UnsignedEvent, now: UnixSeconds, ) -> Result<ProtocolDirectSendResult>

pub fn send_direct_unsigned_event_to_peer_only( &mut self, peer_pubkey: PublicKey, chat_id: &str, rumor: UnsignedEvent, now: UnixSeconds, ) -> Result<ProtocolDirectSendResult>

pub fn send_local_sibling_unsigned_event( &mut self, conversation_owner: PublicKey, chat_id: &str, rumor: UnsignedEvent, now: UnixSeconds, ) -> Result<ProtocolDirectSendResult>

§

impl ProtocolEngine

pub fn process_direct_message_event( &mut self, event: &Event, ) -> Result<Option<ProtocolDecryptedMessage>>

pub fn process_group_outer_event( &mut self, event: &Event, ) -> Result<ProtocolGroupIncomingResult>

pub fn process_group_pairwise_payload( &mut self, payload: &[u8], from_owner_pubkey: PublicKey, from_sender_device_pubkey: Option<PublicKey>, ) -> Result<ProtocolGroupIncomingResult>

pub fn retry_pending_outbound( &mut self, now: NdrUnixSeconds, ) -> Result<Vec<ProtocolRetryResult>>

pub fn retry_pending_protocol( &mut self, now: NdrUnixSeconds, ) -> Result<ProtocolRetryBatch>

pub fn ack_pending_decrypted_deliveries(&mut self) -> Result<()>

§

impl ProtocolEngine

pub fn acknowledge_delivered_group_sender_key_message( &mut self, group_id: &str, sender_owner: PublicKey, sender_device: Option<PublicKey>, created_at_secs: u64, ) -> bool

§

impl ProtocolEngine

pub fn enter_batch(&self)

pub fn exit_batch(&self) -> Result<()>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V