Thread-safe in-memory implementation of PrismState using ZIO Ref.
Stores all events and indices in memory using immutable maps. Suitable for testing, development, and small datasets where persistence is not required. Not recommended for production use with large datasets.
==Event Chain Tracking==
This implementation tracks event chains by recursively following previousEventHash references:
- Create operations establish the root of a chain
- Update/Deactivate operations reference previous events
- Helper methods
ssiFromPreviousEventHashandvdrFromPreviousEventHashtraverse chains to find roots
==Thread Safety==
All state updates use ZIO Ref for lock-free, thread-safe mutations. Multiple concurrent operations are safely handled without explicit locking.
Value parameters
- ref
-
ZIO Ref containing mutable PrismStateInMemoryData
Attributes
- Constructor
-
Creates in-memory state with ZIO Ref
- Example
-
for { state <- PrismStateInMemory.empty _ <- state.addEvent(createEvent) _ <- state.addEvent(updateEvent) ssi <- state.getSSI(didSubject) docs <- state.didDocuments } yield (ssi, docs) - Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait PrismStatetrait PrismStateReadclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
We add/index events with out validating them.
We add/index events with out validating them.
Validation is then when it's been resolved.
Attributes
- Definition Classes
Attributes
- Returns
-
EventCursor of the latest Event
Extracts DID Documents from all SSI states.
Extracts DID Documents from all SSI states.
Attributes
Gets a specific event by its EventHash.
Returns event references for a specific SSI DID.
Returns event references for a specific VDR.
Constructs SSI states for all DIDs in memory.
Constructs SSI states for all DIDs in memory.
Builds resolved SSI objects by folding events for each DID in order.
Attributes
Returns mapping of all SSI DIDs to their event references.
Returns mapping of all SSI DIDs to their event references.
Attributes
- Note
-
TODO: make it a Stream of (DIDSubject, Seq[EventRef])
- Definition Classes
Recursively traverses event chain to find the root SSI hash.
Recursively traverses event chain to find the root SSI hash.
Follows previousEventHash references backward through Update operations until reaching the Create operation.
Value parameters
- previousHash
-
The event hash to start traversal from
Attributes
- Returns
-
ZIO effect with optional root hash (hash of CreateDidOP)
- Note
-
TODO: @scala.annotation.tailrec - Error 'Cannot rewrite recursive call - not in tail position'
Returns mapping of all VDRs to their event references.
Returns mapping of all VDRs to their event references.
Attributes
- Note
-
TODO: make it a Stream of (RefVDR, Seq[EventRef])
- Definition Classes
Recursively traverses event chain to find the root VDR reference.
Recursively traverses event chain to find the root VDR reference.
Follows previousEventHash references backward through Update operations until reaching the Create operation.
Attributes
- Note
-
TODO: @scala.annotation.tailrec - Error 'Cannot rewrite recursive call - not in tail position'
Inherited methods
Adds an event after filtering out invalid ones.
Adds an event after filtering out invalid ones.
Only valid MySignedPrismEvent instances are added; invalid objects are silently ignored.
Attributes
- Inherited from:
- PrismState
Fetches all events in the chain for the given DID.
Fetches all events in the chain for the given DID.
Attributes
- Returns
-
ZIO effect that may fail with
Throwable(RuntimeException if event hash missing or type validation fails) and succeeds with sequence of DID-related MySignedPrismEvent - Inherited from:
- PrismStateRead
Fetches all events in the chain for the given VDR reference.
Fetches all events in the chain for the given VDR reference.
Value parameters
- refVDR
-
The VDR reference to query
Attributes
- Returns
-
ZIO effect that may fail with
Throwable(RuntimeException if event hash missing or type validation fails) and succeeds with sequence of storage-related MySignedPrismEvent - Inherited from:
- PrismStateRead
Gets the current SSI state.
Gets the full SSIHistory for a SSI.
Gets the VDR state with full ownership validation.
Returns the last synced block timestamp.
Returns the last synced block timestamp.
Attributes
- Returns
-
Tuple of (epoch seconds, nanoseconds)
- Note
-
Current implementation returns current time (FIXME: should track actual sync state)
- Inherited from:
- PrismStateRead
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product
Returns count of SSI DIDs in the state.
Returns count of SSI DIDs in the state.
Attributes
- Note
-
TODO: improve in specific implementations for better performance
- Inherited from:
- PrismStateRead
Returns count of VDRs in the state.
Returns count of VDRs in the state.
Attributes
- Note
-
TODO: improve in specific implementations for better performance
- Inherited from:
- PrismStateRead