···37373838An MST is comprised of one or more Nodes. :py:mod:`atmst` represents Nodes using :meth:`~atmst.mst.node.MSTNode`, an immutable dataclass.
39394040-Nodes are ultimately stored in a BlockStore, serialised as `DAG-CBOR <https://ipld.io/docs/codecs/known/dag-cbor/>`_, and the :meth:`~atmst.mst.node_store.NodeStore` class facilitates this. A NodeStore also maintains an LRU cache, mapping CIDs to MSTNode objects, to reduce the impact of BlockStore read latency, hash verification, and deserialisation overheads.
4040+Nodes are stored in a BlockStore, serialised as `DAG-CBOR <https://ipld.io/docs/codecs/known/dag-cbor/>`_, and the :meth:`~atmst.mst.node_store.NodeStore` class handles this transparently. A NodeStore internally maintains an LRU cache, mapping CIDs to MSTNode objects, to reduce the impacts of BlockStore read latency, hash verification, and deserialisation overheads.
41414242-The :meth:`~atmst.mst.node_wrangler.NodeWrangler` class facilitates modifications to MSTs, and the :meth:`~atmst.mst.node_walker.NodeWalker` class facilitates access to MSTs, which the :meth:`~atmst.mst.diff.mst_diff` method makes use of.
4242+The :meth:`~atmst.mst.node_wrangler.NodeWrangler` class facilitates modifications to MSTs, via the :meth:`~atmst.mst.node_wrangler.NodeWrangler.put_record` and :meth:`~atmst.mst.node_wrangler.NodeWrangler.delete_record` methods. These methods each return a CID reference to the new MST root, with any newly created Nodes tracked internally using a :meth:`~atmst.mst.node_store.NodeStore`.
4343+4444+For reading MSTs, the :meth:`~atmst.mst.node_walker.NodeWalker` class acts as a "cursor" for walking the tree from a given starting point (usually the root), including convenience methods for accessing records by key.
4545+4646+The :meth:`~atmst.mst.diff.mst_diff` method makes use of :meth:`~atmst.mst.node_walker.NodeWalker` internally.
4747+4848+=======
4949+Recipes
5050+=======
5151+5252+For some examples of how all these components fit together, check out the source of `cartool.py <https://github.com/DavidBuchanan314/atmst/blob/main/src/atmst/cartool.py>`_.
5353+5454+TODO: Improve this part of the docs!
+3-2
src/atmst/mst/diff.py
···75757676def mst_diff(ns: NodeStore, root_a: CID, root_b: CID) -> Tuple[Set[CID], Set[CID]]: # created, deleted
7777 """
7878- Given two MST root node CIDs, efficiently compute the difference between them, represented as
7979- two sets holding the created and deleted MST nodes respectively (referenced by CIDs).
7878+ XXX: This implementation is not yet ready for prime-time!
7979+8080+ Given two MST root node CIDs, efficiently compute the difference between the two trees. The result is two sets, holding the created and deleted MST nodes respectively (referenced by CIDs).
8081 """
8182 created = set() # MST nodes in b but not in a
8283 deleted = set() # MST nodes in a but not in b