| License | Apache-2.0 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Singular.Registry.Trie.PureManager
Description
In-memory implementation of the TrieManager
interface backed by a 'Map TokenId (IORef
MPFInMemoryDB)'. Each token gets its own isolated
in-memory MPF database; speculative sessions compute in State over a
snapshot so the original is never mutated and no mutable copy is allocated.
The legacy PureManager and mkPureTrieManager names describe the backend,
not the effects. Each caller owns one manager for its serial transaction
builder, replay, evolving fixture or persisted-mirror run. The manager and
dump action must not escape that lifetime into overlapping sessions. There
is no locking: creation, deletion, visibility, reads, writes, dumps and
speculative copying all require external serialization if shared.
Missing and hidden tries retain their legacy ErrorCall failures, respectively
Trie not found: and Trie is hidden: followed by the token's show.
Use the pure snapshot functions in Singular.Registry.Trie.Pure for
deterministic computation; a snapshot has neither registry lookup nor hidden
state. No mutable manager is needed to read its root or prove a leaf.
Synopsis
- mkPureTrieManager :: IO (TrieManager IO)
- mkPureTrieManagerFrom :: Map TokenId MPFInMemoryDB -> IO (TrieManager IO, IO (Map TokenId MPFInMemoryDB))
- dumpPureTries :: IORef (Map TokenId (IORef MPFInMemoryDB)) -> IO (Map TokenId MPFInMemoryDB)
Construction
mkPureTrieManager :: IO (TrieManager IO) Source #
Create a new 'TrieManager IO' backed by a Map
of per-token in-memory MPF databases.
Carrying a mirror between runs
mkPureTrieManagerFrom :: Map TokenId MPFInMemoryDB -> IO (TrieManager IO, IO (Map TokenId MPFInMemoryDB)) Source #
A manager seeded with tries a previous run left behind, paired with the action that reads them back out.
An in-memory trie dies with the process, which is right for a runner that boots its own registry. A runner attaching to a registry that outlives it needs the trie that registry already has: the proofs it builds are against the whole trie, not just the root the chain reports. This is the seam that lets one run hand that trie to the next.
dumpPureTries :: IORef (Map TokenId (IORef MPFInMemoryDB)) -> IO (Map TokenId MPFInMemoryDB) Source #
Read every trie the manager holds back out, so a run can hand what it built to the next one. This includes hidden tries. The owner must exclude concurrent mutation while dumping; the reads are not an atomic snapshot.