this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

mst: add a node kind type, tweak some docs (#143)

authored by

Whyrusleeping and committed by
GitHub
2311acc0 93b159a0

+12 -7
+12 -7
mst/mst.go
··· 1 - // Merkle Search Tree (MST) implementation for atproto. 1 + // Package mst contains a Merkle Search Tree (MST) implementation for atproto. 2 + // 2 3 // This implementation is a port of the Typescript implementation in the 3 4 // `atproto` git repo. 4 5 // ··· 39 40 // If the first leaf in a tree is `bsky/posts/abcdefg` and the second is `bsky/posts/abcdehi` 40 41 // Then the first will be described as `prefix: 0, key: 'bsky/posts/abcdefg'`, 41 42 // and the second will be described as `prefix: 16, key: 'hi'.` 42 - 43 43 package mst 44 44 45 45 import ( ··· 50 50 cbor "github.com/ipfs/go-ipld-cbor" 51 51 ) 52 52 53 + // NodeKind is the type of node in the MST. 54 + type NodeKind uint8 55 + 53 56 const ( 54 - EntryUndefined = 0 55 - EntryLeaf = 1 56 - EntryTree = 2 57 + EntryUndefined NodeKind = 0 58 + EntryLeaf NodeKind = 1 59 + EntryTree NodeKind = 2 57 60 ) 58 61 62 + // NodeEntry is a node in the MST. 63 + // 59 64 // Following the Typescript implementation, this is basically a flexible 60 65 // "TreeEntry" (aka "leaf") which might also be the "Left" pointer on a 61 - // NodeData (aka "tree"). This type flexibility is not idiomatic in golang, but 66 + // NodeData (aka "tree"). This type flexibility is not idiomatic in Go, but 62 67 // we are keeping this a very direct port. 63 68 type NodeEntry struct { 64 - Kind int 69 + Kind NodeKind 65 70 Key string 66 71 Val cid.Cid 67 72 Tree *MerkleSearchTree