| License | Apache-2.0 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Singular.Registry.Deployment.Mirror
Contents
Description
One owner for the deployment's one non-chain dependency: the proof mirror written beside a manifest, per registry token, as the four hex-encoded key/value maps an in-memory MPF database is. Reading and writing the file live here; loading one never queries a node, and the caller — not this module — compares a loaded trie's root against the chain's after attaching.
This module is an internal owner behind the Deployment
facade: callers import the facade, which re-exports the unchanged public
surface. It reads mirrorPathFor, hex and die from
Singular.Registry.Deployment.Manifest, so the mirror's path has one
owner.
Synopsis
- newtype Mirror = Mirror {
- mirrorTries :: [MirrorTrie]
- data MirrorTrie = MirrorTrie {}
- loadMirror :: FilePath -> IO (Map TokenId MPFInMemoryDB)
- saveMirror :: FilePath -> Map TokenId MPFInMemoryDB -> IO ()
- replaceDurably :: FilePath -> ByteString -> IO ()
The proof mirror
The tries a run needs, as the file beside the manifest carries them: per registry token, the four key/value maps an in-memory MPF database is, hex-encoded so the file stays diffable.
Constructors
| Mirror | |
Fields
| |
Instances
| FromJSON Mirror Source # | |||||
Defined in Singular.Registry.Deployment.Mirror | |||||
| ToJSON Mirror Source # | |||||
| Generic Mirror Source # | |||||
Defined in Singular.Registry.Deployment.Mirror Associated Types
| |||||
| Show Mirror Source # | |||||
Defined in Singular.Registry.Deployment.Mirror | |||||
| Eq Mirror Source # | |||||
Defined in Singular.Registry.Deployment.Mirror | |||||
| type Rep Mirror Source # | |||||
Defined in Singular.Registry.Deployment.Mirror type Rep Mirror = D1 ('MetaData "Mirror" "Singular.Registry.Deployment.Mirror" "singular-registry-0.1.0.0-Ixhbs5JE28qkUXbRQkkWU" 'True) (C1 ('MetaCons "Mirror" 'PrefixI 'True) (S1 ('MetaSel ('Just "mirrorTries") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [MirrorTrie]))) | |||||
data MirrorTrie Source #
One registry's trie.
Constructors
| MirrorTrie | |
Instances
| FromJSON MirrorTrie Source # | |||||
Defined in Singular.Registry.Deployment.Mirror Methods parseJSON :: Value -> Parser MirrorTrie parseJSONList :: Value -> Parser [MirrorTrie] omittedField :: Maybe MirrorTrie | |||||
| ToJSON MirrorTrie Source # | |||||
Defined in Singular.Registry.Deployment.Mirror Methods toJSON :: MirrorTrie -> Value toEncoding :: MirrorTrie -> Encoding toJSONList :: [MirrorTrie] -> Value toEncodingList :: [MirrorTrie] -> Encoding omitField :: MirrorTrie -> Bool | |||||
| Generic MirrorTrie Source # | |||||
Defined in Singular.Registry.Deployment.Mirror Associated Types
| |||||
| Show MirrorTrie Source # | |||||
Defined in Singular.Registry.Deployment.Mirror Methods showsPrec :: Int -> MirrorTrie -> ShowS Source # show :: MirrorTrie -> String Source # showList :: [MirrorTrie] -> ShowS Source # | |||||
| Eq MirrorTrie Source # | |||||
Defined in Singular.Registry.Deployment.Mirror Methods (==) :: MirrorTrie -> MirrorTrie -> Bool Source # (/=) :: MirrorTrie -> MirrorTrie -> Bool Source # | |||||
| type Rep MirrorTrie Source # | |||||
Defined in Singular.Registry.Deployment.Mirror type Rep MirrorTrie = D1 ('MetaData "MirrorTrie" "Singular.Registry.Deployment.Mirror" "singular-registry-0.1.0.0-Ixhbs5JE28qkUXbRQkkWU" 'False) (C1 ('MetaCons "MirrorTrie" 'PrefixI 'True) ((S1 ('MetaSel ('Just "mtToken") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "mtMpf") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [(Text, Text)])) :*: (S1 ('MetaSel ('Just "mtKv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [(Text, Text)]) :*: (S1 ('MetaSel ('Just "mtJournal") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [(Text, Text)]) :*: S1 ('MetaSel ('Just "mtMetrics") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [(Text, Text)]))))) | |||||
loadMirror :: FilePath -> IO (Map TokenId MPFInMemoryDB) Source #
Read the mirror beside a manifest. A missing file is the empty mirror, which is what a registry booted a moment ago actually has — the caller that attaches compares the loaded root with the chain's, so an empty mirror against a registry that has grown is refused by that comparison rather than assumed.
saveMirror :: FilePath -> Map TokenId MPFInMemoryDB -> IO () Source #
Write the mirror beside a manifest, replacing what was there whole
or not at all (replaceDurably).
replaceDurably :: FilePath -> ByteString -> IO () Source #
Replace a file whole, durably: the bytes go to a sibling
PATH.partial, synchronised to disk, which is then renamed over PATH,
and the directory is synchronised. A process killed at any point leaves
PATH holding either its previous bytes or the new ones, never a
prefix; a killed replacement may leave the .partial sibling, which the
next replacement overwrites.