pub struct GroupCrdt<ID, OP, M, C, RS> { /* private fields */ }Expand description
Core group CRDT for maintaining group membership state in a decentralized system.
Group members can be assigned different access levels, where only a sub-set of members can mutate the state of the group itself. Group members can be (immutable) individuals or (mutable) sub-groups.
The core data type is a Directed Acyclic Graph of all operations containing group management actions. Operations refer to the previous global state (set of graph tips) in their “dependencies” field, this is the local state when an actor creates a new auth action; these references make up the edges in the graph.
A requirement of the protocol is that all messages are processed in partial-order. When using a dependency graph structure (as is the case in this implementation) it is possible to achieve partial-ordering by only processing a message once all it’s dependencies have themselves been processed.
Group state is maintained using the state object GroupMembersState. Every
time an action is processed, a new state is generated and added to the map
of all states. When a new operation is received, it’s previous state is
calculated and then the message applied, resulting in a new state.
Group membership rules are checked when an action is applied to the previous
state, read more in the crdt::state module.
The struct has several generic parameters which allow users to specify their own core types and to customise behavior when handling concurrent changes when resolving a graph to it’s final state.
- ID : identifier for both an individual actor and group.
- OP : identifier for an operation.
- C : conditions which restrict an access level.
- RS : generic resolver which contains logic for deciding when group state
rebuilds are required, and how concurrent actions are handled. See the
resolvermodule for different implementations. - ORD: orderer which exposes an API for creating and processing operations with meta-data which allow them to be processed in partial order.
Implementations§
Source§impl<ID, OP, M, C, RS> GroupCrdt<ID, OP, M, C, RS>where
ID: IdentityHandle,
OP: OperationId + Ord,
M: Operation<ID, OP, C> + Clone,
C: Conditions,
RS: Resolver<ID, OP, M, C, State = GroupCrdtInnerState<ID, OP, M, C>>,
impl<ID, OP, M, C, RS> GroupCrdt<ID, OP, M, C, RS>where
ID: IdentityHandle,
OP: OperationId + Ord,
M: Operation<ID, OP, C> + Clone,
C: Conditions,
RS: Resolver<ID, OP, M, C, State = GroupCrdtInnerState<ID, OP, M, C>>,
pub fn init() -> GroupCrdtState<ID, OP, M, C>
Sourcepub fn process(
y: GroupCrdtState<ID, OP, M, C>,
operation: &M,
) -> Result<GroupCrdtState<ID, OP, M, C>, GroupCrdtError<ID, OP, M, C, RS>>
pub fn process( y: GroupCrdtState<ID, OP, M, C>, operation: &M, ) -> Result<GroupCrdtState<ID, OP, M, C>, GroupCrdtError<ID, OP, M, C, RS>>
Process an operation created locally or received from a remote peer.