···11-// Merkle Search Tree (MST) implementation for atproto.
11+// Package mst contains a Merkle Search Tree (MST) implementation for atproto.
22+//
23// This implementation is a port of the Typescript implementation in the
34// `atproto` git repo.
45//
···3940// If the first leaf in a tree is `bsky/posts/abcdefg` and the second is `bsky/posts/abcdehi`
4041// Then the first will be described as `prefix: 0, key: 'bsky/posts/abcdefg'`,
4142// and the second will be described as `prefix: 16, key: 'hi'.`
4242-4343package mst
44444545import (
···5050 cbor "github.com/ipfs/go-ipld-cbor"
5151)
52525353+// NodeKind is the type of node in the MST.
5454+type NodeKind uint8
5555+5356const (
5454- EntryUndefined = 0
5555- EntryLeaf = 1
5656- EntryTree = 2
5757+ EntryUndefined NodeKind = 0
5858+ EntryLeaf NodeKind = 1
5959+ EntryTree NodeKind = 2
5760)
58616262+// NodeEntry is a node in the MST.
6363+//
5964// Following the Typescript implementation, this is basically a flexible
6065// "TreeEntry" (aka "leaf") which might also be the "Left" pointer on a
6161-// NodeData (aka "tree"). This type flexibility is not idiomatic in golang, but
6666+// NodeData (aka "tree"). This type flexibility is not idiomatic in Go, but
6267// we are keeping this a very direct port.
6368type NodeEntry struct {
6464- Kind int
6969+ Kind NodeKind
6570 Key string
6671 Val cid.Cid
6772 Tree *MerkleSearchTree