Header menu logo FSharp.ATProto

Mst Module

Merkle Search Tree (MST) data structure for AT Protocol repositories.

Types

Type Description

Entry

An entry in an MST node.

Node

An MST node.

Functions and values

Function or value Description

allEntries node

Full Usage: allEntries node

Parameters:
Returns: (string * Cid) list

Collect all (key, value) pairs from an MST in sorted order.

node : Node
Returns: (string * Cid) list

commonPrefixLen a b

Full Usage: commonPrefixLen a b

Parameters:
    a : string
    b : string

Returns: int

Compute the common prefix length between two strings.

a : string
b : string
Returns: int

create entries

Full Usage: create entries

Parameters:
    entries : (string * Cid) list

Returns: Node

Build an MST from a sorted list of (key, valueCid) pairs. Higher heightForKey values = closer to root. Layer 0 = leaf level.

entries : (string * Cid) list
Returns: Node

delete key node

Full Usage: delete key node

Parameters:
    key : string
    node : Node

Returns: Node

Delete a key from the MST. Rebuilds the tree.

key : string
node : Node
Returns: Node

deserialize blocks cid

Full Usage: deserialize blocks cid

Parameters:
    blocks : Map<string, byte[]>
    cid : Cid

Returns: Result<Node, string>

Deserialize an MST from a block store starting from a root CID.

blocks : Map<string, byte[]>
cid : Cid
Returns: Result<Node, string>

diff oldNode newNode

Full Usage: diff oldNode newNode

Parameters:
Returns: (string * Cid) list * (string * Cid) list * string list

Diff two MSTs, returning (added, updated, deleted) key-value pairs.

oldNode : Node
newNode : Node
Returns: (string * Cid) list * (string * Cid) list * string list

empty

Full Usage: empty

Returns: Node

An empty MST.

Returns: Node

heightForKey key

Full Usage: heightForKey key

Parameters:
    key : string

Returns: int

Compute the MST height (layer) for a key. Counts leading zero 2-bit pairs in the SHA-256 hash of the key's UTF-8 bytes.

key : string
Returns: int

insert key value node

Full Usage: insert key value node

Parameters:
    key : string
    value : Cid
    node : Node

Returns: Node

Insert a key-value pair into the MST. Rebuilds the tree.

key : string
value : Cid
node : Node
Returns: Node

lookup key node

Full Usage: lookup key node

Parameters:
    key : string
    node : Node

Returns: Cid option

Look up a key in the MST.

key : string
node : Node
Returns: Cid option

serialize node

Full Usage: serialize node

Parameters:
Returns: Cid * Map<string, byte[]>

Serialize an MST node to DAG-CBOR and return (CID, block map).

node : Node
Returns: Cid * Map<string, byte[]>

Type something to start searching.