barrel_p2p_crdt_wire (barrel_p2p v0.1.0)
View SourceSummary
Functions
Keep only the entries that pass valid_entry/2. Guards the top-level argument: a non-map payload (a malformed broadcast can deliver any term) returns #{} rather than letting maps:filter crash. The helper never crashes the caller on any peer-supplied term.
Validate, absorb the incoming clock, and merge into Local. Returns {Merged, Accepted}: Merged is the new local OR-Map and Accepted is the validated sub-map of incoming entries - the keys that changed, so the caller can update its projection and emit events without rescanning the whole map. A non-map Incoming is a no-op: {Local, #{}}. Works identically for a delta and a full-sync snapshot.
Wrapper-only validity: the entry shape absorb_clock/merge require (a value with a non-empty dot map keyed by {node(), HLC}, or a tombstone carrying an HLC). Accepts any leaf value.
Wrapper validity plus an application leaf-value check.
Types
Functions
-spec accept(term(), leaf_validator()) -> barrel_p2p_ormap:ormap().
Keep only the entries that pass valid_entry/2. Guards the top-level argument: a non-map payload (a malformed broadcast can deliver any term) returns #{} rather than letting maps:filter crash. The helper never crashes the caller on any peer-supplied term.
-spec ingest(barrel_p2p_ormap:ormap(), term(), leaf_validator()) -> {barrel_p2p_ormap:ormap(), barrel_p2p_ormap:ormap()}.
Validate, absorb the incoming clock, and merge into Local. Returns {Merged, Accepted}: Merged is the new local OR-Map and Accepted is the validated sub-map of incoming entries - the keys that changed, so the caller can update its projection and emit events without rescanning the whole map. A non-map Incoming is a no-op: {Local, #{}}. Works identically for a delta and a full-sync snapshot.
Wrapper-only validity: the entry shape absorb_clock/merge require (a value with a non-empty dot map keyed by {node(), HLC}, or a tombstone carrying an HLC). Accepts any leaf value.
-spec valid_entry(term(), leaf_validator()) -> boolean().
Wrapper validity plus an application leaf-value check.