pub struct ChatRoomStateV1 {
pub configuration: AuthorizedConfigurationV1,
pub bans: BansV1,
pub members: MembersV1,
pub member_info: MemberInfoV1,
pub secrets: RoomSecretsV1,
pub recent_messages: MessagesV1,
pub direct_messages: DirectMessagesV1,
pub upgrade: OptionalUpgradeV1,
pub version: StateVersion,
}Fields§
§configuration: AuthorizedConfigurationV1Configures things like maximum message length, can be updated by the owner.
bans: BansV1A list of recently banned members, a banned member can’t be present in the members list and will be removed from it ifc necessary.
members: MembersV1The members in the chat room along with who invited them
member_info: MemberInfoV1Metadata about members like their nickname, can be updated by members themselves.
secrets: RoomSecretsV1Secret distribution for private rooms. Must come before recent_messages so message validation can check secret version consistency.
recent_messages: MessagesV1The most recent messages in the chat room, the number is limited by the room configuration.
direct_messages: DirectMessagesV1In-room encrypted direct messages between members (#230 Phase 1).
#[serde(default)] keeps states written before this field was added
backwards-compatible.
upgrade: OptionalUpgradeV1If this contract has been replaced by a new contract this will contain the new contract address. This can only be set by the owner.
version: StateVersionState format version for migration compatibility. Defaults to 0 for backward compatibility with states created before versioning.
Implementations§
Source§impl ChatRoomStateV1
impl ChatRoomStateV1
Sourcepub fn post_apply_cleanup(
&mut self,
parameters: &ChatRoomParametersV1,
) -> Result<(), String>
pub fn post_apply_cleanup( &mut self, parameters: &ChatRoomParametersV1, ) -> Result<(), String>
Post-apply cleanup: prune members who have no recent messages, clean up member_info for pruned members, remove orphaned bans, and sweep direct messages whose participants are no longer in the room.
Members are kept if they have at least one message in recent_messages,
are a sender/recipient of a currently-held direct message (see
crate::room_state::direct_messages::DirectMessagesV1::active_participants),
or are in the invite chain of someone who qualifies. The owner is
never in the members list (they’re implicit via parameters).
Bans are only removed if the banner was themselves BANNED (orphaned ban). If the banner was merely pruned for inactivity, their bans persist.
IDEMPOTENCE / CONVERGENCE INVARIANT: this function MUST be idempotent
(cleanup(S) == cleanup(cleanup(S))) and a pure function of the converged
state, because Freenet runs it a variable number of times across peers
(and full-state PUTs bypass it via verify). The max_user_bans cap is
therefore applied at the TOP (step 0-cap) so ban enforcement and the
banner-prune exemption read the FINAL surviving ban set — see the block
comments below and #411 round 7 / Codex P1 #1+#2.
Direct-message sweep: after pruning, any DM whose sender or
recipient is now non-member or banned is dropped. Without this,
adding a ban for a DM participant would silently make every
peer’s verify fail, and members referenced only by a DM would be
pruned (orphaning their DMs). See
direct_messages.rs module docs, “Interaction with bans”.
Trait Implementations§
Source§impl Clone for ChatRoomStateV1
impl Clone for ChatRoomStateV1
Source§fn clone(&self) -> ChatRoomStateV1
fn clone(&self) -> ChatRoomStateV1
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ComposableState for ChatRoomStateV1
impl ComposableState for ChatRoomStateV1
type ParentState = ChatRoomStateV1
type Summary = ChatRoomStateV1Summary
type Delta = ChatRoomStateV1Delta
type Parameters = <AuthorizedConfigurationV1 as ComposableState>::Parameters
fn verify( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, ) -> Result<(), String>
fn summarize( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, ) -> Self::Summary
fn delta( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, old_state_summary: &Self::Summary, ) -> Option<Self::Delta>
Source§fn apply_delta(
&mut self,
_parent_state: &Self::ParentState,
parameters: &Self::Parameters,
delta: &Option<Self::Delta>,
) -> Result<(), String>
fn apply_delta( &mut self, _parent_state: &Self::ParentState, parameters: &Self::Parameters, delta: &Option<Self::Delta>, ) -> Result<(), String>
delta to the current state. Read more