ExWapp.AppState.Engine.State (ExWapp v0.1.2)

Copy Markdown View Source

Persistence helpers for app-state hash-chain metadata.

The app-state protocol tracks a per-collection LTHash version and a mutation MAC cache. This module keeps those storage concerns separate from transport and decoding logic.

Summary

Functions

Returns the collection names tracked by the app-state engine.

Loads the saved hash state and mutation MACs for one collection.

Persists the current hash state and mutation MACs for one collection.

Drops a collection's stored version, hash and mutation MACs so the next fetch starts over from a snapshot.

Types

hash_state()

@type hash_state() :: %{version: non_neg_integer(), hash: binary()}

Functions

all_collections()

@spec all_collections() :: [String.t()]

Returns the collection names tracked by the app-state engine.

get_collection_state(store, collection_name)

@spec get_collection_state(
  struct(),
  String.t()
) :: {:ok, hash_state(), map()}

Loads the saved hash state and mutation MACs for one collection.

persist_collection_state(store, collection_name, hash_state, mutation_macs)

@spec persist_collection_state(struct(), String.t(), hash_state(), map()) :: :ok

Persists the current hash state and mutation MACs for one collection.

reset_collection_state(store, collection_name)

@spec reset_collection_state(
  struct(),
  String.t()
) :: :ok

Drops a collection's stored version, hash and mutation MACs so the next fetch starts over from a snapshot.