Skip to content

Commit

Permalink
Document IndexMap and ClientMap
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed May 2, 2023
1 parent 9f14837 commit 3287ad8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions services/galley/src/Galley/API/MLS/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ import Wire.API.MLS.Credential
import Wire.API.MLS.LeafNode
import Wire.API.MLS.SubConversation

-- | A map of leaf index to members.
--
-- This is used to reconstruct client
-- identities from leaf indices in remove proposals, as well as to allocate new
-- indices for added clients.
--
-- Note that clients that are in the process of being removed from a group
-- (i.e. there is a pending remove proposals for them) are included in this
-- mapping.
newtype IndexMap = IndexMap {unIndexMap :: IntMap ClientIdentity}
deriving (Eq, Show)
deriving newtype (Semigroup, Monoid)
Expand All @@ -58,6 +67,14 @@ imRemoveClient im idx = do
cid <- imLookup im idx
pure (cid, IndexMap . IntMap.delete (fromIntegral idx) $ unIndexMap im)

-- | A two-level map of users to clients to leaf indices.
--
-- This is used to keep track of the state of an MLS group for e.g. propagating
-- a message to all the clients that are supposed to receive it.
--
-- Note that clients that are in the process of being removed from a group
-- (i.e. there is a pending remove proposals for them) are __not__ included in
-- this mapping.
type ClientMap = Map (Qualified UserId) (Map ClientId LeafIndex)

mkClientMap :: [(Domain, UserId, ClientId, Int32, Bool)] -> ClientMap
Expand Down

0 comments on commit 3287ad8

Please sign in to comment.