Here is a diff for turning the above script into a margaret-find.go tool that searches for a message key. Since we don't store the references as strings in base64 we need to compute the ref for each message again...
24,25c24,25
< if len(os.Args) != 3 {
< check(fmt.Errorf("usage: margret-find <log dir> <searchkey>"))
---
> if len(os.Args) != 2 {
> check(fmt.Errorf("usage: margret-dump.go <log dir>"))
35,39d34
< // make sure we get a ref we understand
< // and parse it means we can compare it without encoding it up to b64 again..!
< searchRef, err := ssb.ParseMessageRef(os.Args[2])
< check(err)
<
44,47c39
< src, err := ofstLog.Query(
< margaret.Reverse(true), // read last entries first
< margaret.SeqWrap(true), // also get the sequence (so we don't have to keep track of it ourselvs)
< )
---
> src, err := ofstLog.Query(margaret.Limit(3))
49a42
> i := 0
60,67c53
< // go abstraction magic, now first unbox the sequence-value pair
< sw, ok := msgv.(margaret.SeqWrapper)
< if !ok {
< check(fmt.Errorf("unexpected type: %T", msgv))
< }
< msgv = sw.Value() // message inside here
<
< // now get the message type that's nice to work with
---
> // go abstraction magic, get a message type that's nice to work with
73,79d58
< i := sw.Seq()
<
< if !msg.Key().Equal(*searchRef) {
< // fmt.Println("not found, skipping",i)
< continue
< }
<
81c60,61
< fmt.Printf("\n\nFound Message%02d: %s\n", i, msg.Key().Ref())
---
> fmt.Printf("\n\nMessage%02d: %s\n", i, msg.Key().Ref())
> i++