singular-registry
LicenseApache-2.0
Safe HaskellNone
LanguageGHC2021

Singular.Registry.Deployment.Mirror

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

The proof mirror

newtype Mirror Source #

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

Instances details
FromJSON Mirror Source # 
Instance details

Defined in Singular.Registry.Deployment.Mirror

Methods

parseJSON :: Value -> Parser Mirror

parseJSONList :: Value -> Parser [Mirror]

omittedField :: Maybe Mirror

ToJSON Mirror Source # 
Instance details

Defined in Singular.Registry.Deployment.Mirror

Methods

toJSON :: Mirror -> Value

toEncoding :: Mirror -> Encoding

toJSONList :: [Mirror] -> Value

toEncodingList :: [Mirror] -> Encoding

omitField :: Mirror -> Bool

Generic Mirror Source # 
Instance details

Defined in Singular.Registry.Deployment.Mirror

Associated Types

type Rep Mirror 
Instance details

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])))

Methods

from :: Mirror -> Rep Mirror x Source #

to :: Rep Mirror x -> Mirror Source #

Show Mirror Source # 
Instance details

Defined in Singular.Registry.Deployment.Mirror

Methods

showsPrec :: Int -> Mirror -> ShowS Source #

show :: Mirror -> String Source #

showList :: [Mirror] -> ShowS Source #

Eq Mirror Source # 
Instance details

Defined in Singular.Registry.Deployment.Mirror

Methods

(==) :: Mirror -> Mirror -> Bool Source #

(/=) :: Mirror -> Mirror -> Bool Source #

type Rep Mirror Source # 
Instance details

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 

Fields

  • mtToken :: Text

    Hex asset name of the registry this trie belongs to

  • mtMpf :: [(Text, Text)]
     
  • mtKv :: [(Text, Text)]
     
  • mtJournal :: [(Text, Text)]
     
  • mtMetrics :: [(Text, Text)]
     

Instances

Instances details
FromJSON MirrorTrie Source # 
Instance details

Defined in Singular.Registry.Deployment.Mirror

Methods

parseJSON :: Value -> Parser MirrorTrie

parseJSONList :: Value -> Parser [MirrorTrie]

omittedField :: Maybe MirrorTrie

ToJSON MirrorTrie Source # 
Instance details

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 # 
Instance details

Defined in Singular.Registry.Deployment.Mirror

Associated Types

type Rep MirrorTrie 
Instance details

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)])))))

Methods

from :: MirrorTrie -> Rep MirrorTrie x Source #

to :: Rep MirrorTrie x -> MirrorTrie Source #

Show MirrorTrie Source # 
Instance details

Defined in Singular.Registry.Deployment.Mirror

Methods

showsPrec :: Int -> MirrorTrie -> ShowS Source #

show :: MirrorTrie -> String Source #

showList :: [MirrorTrie] -> ShowS Source #

Eq MirrorTrie Source # 
Instance details

Defined in Singular.Registry.Deployment.Mirror

Methods

(==) :: MirrorTrie -> MirrorTrie -> Bool Source #

(/=) :: MirrorTrie -> MirrorTrie -> Bool Source #

type Rep MirrorTrie Source # 
Instance details

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.