···991010// Helper type for extracting record $type from CBOR
1111type GenericRecord struct {
1212- Type string `json:"$type" cborgen:"$type"`
1212+ Type string `json:"$type" cbor:"$type" cborgen:"$type"`
1313}
14141515// Parses the top-level $type field from generic atproto JSON data
···13131414// atproto repo commit object as a struct type. Can be used for direct CBOR or JSON serialization.
1515type Commit struct {
1616- DID string `json:"did" cborgen:"did"`
1717- Version int64 `json:"version" cborgen:"version"` // currently: 3
1818- Prev *cid.Cid `json:"prev" cborgen:"prev"` // NOTE: omitempty would break signature verification for repo v3
1919- Data cid.Cid `json:"data" cborgen:"data"`
2020- Sig []byte `json:"sig,omitempty" cborgen:"sig,omitempty"`
2121- Rev string `json:"rev,omitempty" cborgen:"rev,omitempty"`
1616+ DID string `json:"did" cbor:"did" cborgen:"did"`
1717+ Version int64 `json:"version" cbor:"version" cborgen:"version"` // currently: 3
1818+ Prev *cid.Cid `json:"prev" cbor:"prev" cborgen:"prev"` // NOTE: omitempty would break signature verification for repo v3
1919+ Data cid.Cid `json:"data" cbor:"data" cborgen:"data"`
2020+ Sig []byte `json:"sig,omitempty" cbor:"sig,omitempty" cborgen:"sig,omitempty"`
2121+ Rev string `json:"rev,omitempty" cbor:"rev,omitempty" cborgen:"rev,omitempty"`
2222}
23232424// does basic checks that field values and syntax are correct
+6-6
atproto/repo/mst/encoding.go
···15151616// CBOR serialization struct for a MST tree node. MST tree node as gets serialized to CBOR. Note that the CBOR fields are all single-character.
1717type NodeData struct {
1818- Left *cid.Cid `cborgen:"l"` // [nullable] pointer to lower-level subtree to the "left" of this path/key
1919- Entries []EntryData `cborgen:"e"` // ordered list of entries at this node
1818+ Left *cid.Cid `cbor:"l" cborgen:"l"` // [nullable] pointer to lower-level subtree to the "left" of this path/key
1919+ Entries []EntryData `cbor:"e" cborgen:"e"` // ordered list of entries at this node
2020}
21212222// CBOR serialization struct for a single entry within a `NodeData` entry list.
2323type EntryData struct {
2424- PrefixLen int64 `cborgen:"p"` // count of characters shared with previous path/key in tree
2525- KeySuffix []byte `cborgen:"k"` // remaining part of path/key (appended to "previous key")
2626- Value cid.Cid `cborgen:"v"` // CID pointer at this path/key
2727- Right *cid.Cid `cborgen:"t"` // [nullable] pointer to lower-level subtree to the "right" of this path/key entry
2424+ PrefixLen int64 `cbor:"p" cborgen:"p"` // count of characters shared with previous path/key in tree
2525+ KeySuffix []byte `cbor:"k" cborgen:"k"` // remaining part of path/key (appended to "previous key")
2626+ Value cid.Cid `cbor:"v" cborgen:"v"` // CID pointer at this path/key
2727+ Right *cid.Cid `cbor:"t" cborgen:"t"` // [nullable] pointer to lower-level subtree to the "right" of this path/key entry
2828}
29293030// Encodes a single `NodeData` struct as CBOR bytes. Does not recursively encode or update children.