this repo has no description
0
fork

Configure Feed

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

mst: tree walk function

+24
+19
atproto/repo/mst/node.go
··· 291 291 return nil 292 292 } 293 293 294 + func (n *Node) walk(f func(key []byte, val cid.Cid) error) error { 295 + if n == nil { 296 + return fmt.Errorf("nil tree pointer") 297 + } 298 + for _, e := range n.Entries { 299 + if e.IsValue() { 300 + if err := f(e.Key, *e.Value); err != nil { 301 + return err 302 + } 303 + } 304 + if e.Child != nil { 305 + if err := e.Child.walk(f); err != nil { 306 + return err 307 + } 308 + } 309 + } 310 + return nil 311 + } 312 + 294 313 // Reads the value (CID) corresponding to the key. If key is not in the tree, returns (nil, nil). 295 314 // 296 315 // n: Node at top of sub-tree to operate on. Must not be nil.
+5
atproto/repo/mst/tree.go
··· 79 79 return t.Root.getCID(key, -1) 80 80 } 81 81 82 + // Walks the Tree, invoking the callback function on each key/value pair. 83 + func (t *Tree) Walk(f func(key []byte, val cid.Cid) error) error { 84 + return t.Root.walk(f) 85 + } 86 + 82 87 // Creates a new Tree by loading key/value pairs from a map. 83 88 func LoadTreeFromMap(m map[string]cid.Cid) (*Tree, error) { 84 89 if m == nil {