singular-registry
LicenseApache-2.0
Safe HaskellNone
LanguageGHC2021

Singular.Registry.Trie

Description

Record-of-functions interface for managing per-token Merkle Patricia Forestry tries. The TrieManager mediates access to individual Trie handles and provides speculative (read-your-writes, then-discard) sessions for transaction building.

Synopsis

Trie manager

data TrieManager (m :: Type -> Type) Source #

Manager for per-token tries.

Constructors

TrieManager 

Fields

  • withTrie :: forall a. TokenId -> (Trie m -> m a) -> m a

    Run an action with access to a token's trie

  • withSpeculativeTrie :: forall a. TokenId -> (forall (n :: Type -> Type). Monad n => Trie n -> n a) -> m a

    Run a read-your-writes session whose mutations are discarded at the end.

  • createTrie :: TokenId -> m ()

    Create a new empty trie for a token

  • deleteTrie :: TokenId -> m ()

    Delete a token's trie (permanent removal)

  • hideTrie :: TokenId -> m ()

    Mark a token's trie as hidden

  • unhideTrie :: TokenId -> m ()

    Restore a hidden token's trie

Single trie operations

data Trie (m :: Type -> Type) Source #

Operations on a single trie.

Constructors

Trie 

Fields

  • insert :: ByteString -> ByteString -> m Root

    Insert a key-value pair, returning new root

  • delete :: ByteString -> m Root

    Delete a key, returning new root

  • lookup :: ByteString -> m (Maybe ByteString)

    Look up a value by key

  • getRoot :: m Root

    Get current root hash

  • getProofSteps :: ByteString -> m (Maybe [ProofStep])

    Generate on-chain proof steps for a key