No description
  • Go 99.7%
  • Nix 0.3%
Find a file
2026-06-27 12:32:53 +02:00
.builds reuse compliance 2021-08-25 09:45:33 +02:00
.github/workflows reuse compliance 2021-08-25 09:45:33 +02:00
bench bench: add blocklog-split-debounced variant for debounced index sync 2026-06-27 12:32:53 +02:00
blocklog blocklog: add split-index mode with separate index file 2026-06-27 12:12:10 +02:00
cmd/roaring-stats stats 2026-03-08 12:17:29 +01:00
docs/plans feat(blocklog): superblock struct, format, read/write 2026-06-21 19:16:19 +02:00
indexes generic iterators 2026-03-02 07:48:06 +01:00
internal shared bbolt 2026-03-08 12:23:02 +01:00
legacyflumeoffset leagcyflumeoffset 2026-03-07 18:15:54 +01:00
LICENSES reuse compliance 2021-08-25 09:45:33 +02:00
mem batch writes 2026-03-07 22:44:26 +01:00
multilog shared bbolt 2026-03-08 12:23:02 +01:00
offset2 dont panic on negative sizes 2026-03-07 23:18:31 +01:00
test generic iterators 2026-03-02 07:48:06 +01:00
.gitignore reuse compliance 2021-08-25 09:45:33 +02:00
AUTHORS update AUTHORS 2021-08-25 09:49:04 +02:00
flake.lock generic iterators 2026-03-02 07:48:06 +01:00
flake.nix generic iterators 2026-03-02 07:48:06 +01:00
go.mod bbolt and badger 2026-03-08 11:27:51 +01:00
go.sum bbolt and badger 2026-03-08 11:27:51 +01:00
go.sum.license reuse compliance 2021-08-25 09:45:33 +02:00
LICENSE MIT license 2019-10-06 14:45:38 +02:00
log.go batch writes 2026-03-07 22:44:26 +01:00
qry.go generic iterators 2026-03-02 07:48:06 +01:00
README.md fix: new ssbc urls 2022-10-20 00:07:21 +03:00
seq.go fix: new ssbc urls 2022-10-20 00:07:21 +03:00
seqwrap.go reuse compliance 2021-08-25 09:45:33 +02:00

Margaret Go Reference Github Actions Tests Go Report Card REUSE status

Margaret is go-ssb's append-only log* provider, and greatly inspired by flumedb. Compatible with Go 1.13+.

margaret the log lady, 1989 edition

the project name is inspired by Twin Peaks's character Margaret aka the log lady

Margaret has the following facilities:

  • an append-only log interface .Append(interface{}), .Get(int64)
  • queries .Query(...QuerySpec) for retrieving ranges based on sequence numbers e.g. .Gt(int64), or limiting the amount of data returned .Limit(int64)
  • a variety of index mechanisms, both for categorizing log entries into buckets and for creating virtual logs (aka sublogs)

Margaret is one of a few key components that make the go implementation of ssb tick, for example:

  • ssb/sbot uses margaret for storing each peer's data

Log storage

Margaret outputs data according to the offset2 format, which is inspired by (but significantly differs from) flumelog-offset.

In brief: margaret stores the data of all logs in the three following files:

  • data stores the actual data (with a length-prefix before each entry)
  • ofst indexes the starting locations for each data entry in data
  • jrnl an integrity checking mechanism for all three files; a checksum of sorts, more details

More details

There are a few concepts that might be tough to digest for newcomers on first approach:

  • multilogs, a kind of tree-based index, where each leaf is a margaret.Log
    • in other words: it creates virtual sublogs that map to entries in an offset log (see log storage above)
  • margaret/indexes similar to leveldb indexes (arbitrary key-value stores)
  • sublogs (and rxLog/receiveLog/offsetLog and its equivalence to offset.log)
  • queries
  • zeroing out, or replacing, written data

For more on these concepts, visit the dev.scutttlebutt.nz portal for in-depth explanations.

* margaret is technically an append-based log, as there is support for both zeroing out and replacing items in the log after they have been written. Given the relative ubiquity of append-only logs & their uses, it's easier to just say append-only log.