Documentation
¶
Index ¶
- Constants
- Variables
- func AddressableEventVars() (p *types.PubHash, ki *types.Uint16, d *types.Ident)
- func CreatedAtVars() (ca *types.Uint64, ser *types.Uint40)
- func EventPubkeyGraphVars() (eventSer *types.Uint40, pubkeySer *types.Uint40, kind *types.Uint16, ...)
- func EventVars() (ser *types.Uint40)
- func ExpirationVars() (exp *types.Uint64, ser *types.Uint40)
- func FullIdPubkeyVars() (ser *types.Uint40, fid *types.Id, p *types.PubHash, ca *types.Uint64)
- func IdVars() (id *types.IdHash, ser *types.Uint40)
- func Identify(r io.Reader) (i int, err error)
- func KindPubkeyVars() (ki *types.Uint16, p *types.PubHash, ca *types.Uint64, ser *types.Uint40)
- func KindVars() (ki *types.Uint16, ca *types.Uint64, ser *types.Uint40)
- func PubkeyEventGraphVars() (pubkeySer *types.Uint40, kind *types.Uint16, direction *types.Letter, ...)
- func PubkeySerialVars() (p *types.PubHash, ser *types.Uint40)
- func PubkeyVars() (p *types.PubHash, ca *types.Uint64, ser *types.Uint40)
- func ReplaceableEventVars() (p *types.PubHash, ki *types.Uint16)
- func SerialPubkeyVars() (ser *types.Uint40)
- func SmallEventVars() (ser *types.Uint40)
- func TagKindPubkeyVars() (k *types.Letter, v *types.Ident, ki *types.Uint16, p *types.PubHash, ...)
- func TagKindVars() (k *types.Letter, v *types.Ident, ki *types.Uint16, ca *types.Uint64, ...)
- func TagPubkeyVars() (k *types.Letter, v *types.Ident, p *types.PubHash, ca *types.Uint64, ...)
- func TagVars() (k *types.Letter, v *types.Ident, ca *types.Uint64, ser *types.Uint40)
- func VersionVars() (ver *types.Uint32)
- func WordVars() (w *types.Word, ser *types.Uint40)
- type Encs
- type I
- type P
- type T
- func AddressableEventDec(p *types.PubHash, ki *types.Uint16, d *types.Ident) (enc *T)
- func AddressableEventEnc(p *types.PubHash, ki *types.Uint16, d *types.Ident) (enc *T)
- func CreatedAtDec(ca *types.Uint64, ser *types.Uint40) (enc *T)
- func CreatedAtEnc(ca *types.Uint64, ser *types.Uint40) (enc *T)
- func EventDec(ser *types.Uint40) (enc *T)
- func EventEnc(ser *types.Uint40) (enc *T)
- func EventPubkeyGraphDec(eventSer *types.Uint40, pubkeySer *types.Uint40, kind *types.Uint16, ...) (enc *T)
- func EventPubkeyGraphEnc(eventSer *types.Uint40, pubkeySer *types.Uint40, kind *types.Uint16, ...) (enc *T)
- func ExpirationDec(exp *types.Uint64, ser *types.Uint40) (enc *T)
- func ExpirationEnc(exp *types.Uint64, ser *types.Uint40) (enc *T)
- func FullIdPubkeyDec(ser *types.Uint40, fid *types.Id, p *types.PubHash, ca *types.Uint64) (enc *T)
- func FullIdPubkeyEnc(ser *types.Uint40, fid *types.Id, p *types.PubHash, ca *types.Uint64) (enc *T)
- func IdDec(id *types.IdHash, ser *types.Uint40) (enc *T)
- func IdEnc(id *types.IdHash, ser *types.Uint40) (enc *T)
- func KindDec(ki *types.Uint16, ca *types.Uint64, ser *types.Uint40) (enc *T)
- func KindEnc(ki *types.Uint16, ca *types.Uint64, ser *types.Uint40) (enc *T)
- func KindPubkeyDec(ki *types.Uint16, p *types.PubHash, ca *types.Uint64, ser *types.Uint40) (enc *T)
- func KindPubkeyEnc(ki *types.Uint16, p *types.PubHash, ca *types.Uint64, ser *types.Uint40) (enc *T)
- func New(encoders ...codec.I) (i *T)
- func PubkeyDec(p *types.PubHash, ca *types.Uint64, ser *types.Uint40) (enc *T)
- func PubkeyEnc(p *types.PubHash, ca *types.Uint64, ser *types.Uint40) (enc *T)
- func PubkeyEventGraphDec(pubkeySer *types.Uint40, kind *types.Uint16, direction *types.Letter, ...) (enc *T)
- func PubkeyEventGraphEnc(pubkeySer *types.Uint40, kind *types.Uint16, direction *types.Letter, ...) (enc *T)
- func PubkeySerialDec(p *types.PubHash, ser *types.Uint40) (enc *T)
- func PubkeySerialEnc(p *types.PubHash, ser *types.Uint40) (enc *T)
- func ReplaceableEventDec(p *types.PubHash, ki *types.Uint16) (enc *T)
- func ReplaceableEventEnc(p *types.PubHash, ki *types.Uint16) (enc *T)
- func SerialPubkeyDec(ser *types.Uint40) (enc *T)
- func SerialPubkeyEnc(ser *types.Uint40) (enc *T)
- func SmallEventDec(ser *types.Uint40) (enc *T)
- func SmallEventEnc(ser *types.Uint40) (enc *T)
- func TagDec(k *types.Letter, v *types.Ident, ca *types.Uint64, ser *types.Uint40) (enc *T)
- func TagEnc(k *types.Letter, v *types.Ident, ca *types.Uint64, ser *types.Uint40) (enc *T)
- func TagKindDec(k *types.Letter, v *types.Ident, ki *types.Uint16, ca *types.Uint64, ...) (enc *T)
- func TagKindEnc(k *types.Letter, v *types.Ident, ki *types.Uint16, ca *types.Uint64, ...) (enc *T)
- func TagKindPubkeyDec(k *types.Letter, v *types.Ident, ki *types.Uint16, p *types.PubHash, ...) (enc *T)
- func TagKindPubkeyEnc(k *types.Letter, v *types.Ident, ki *types.Uint16, p *types.PubHash, ...) (enc *T)
- func TagPubkeyDec(k *types.Letter, v *types.Ident, p *types.PubHash, ca *types.Uint64, ...) (enc *T)
- func TagPubkeyEnc(k *types.Letter, v *types.Ident, p *types.PubHash, ca *types.Uint64, ...) (enc *T)
- func VersionDec(ver *types.Uint32) (enc *T)
- func VersionEnc(ver *types.Uint32) (enc *T)
- func WordDec(w *types.Word, ser *types.Uint40) (enc *T)
- func WordEnc(w *types.Word, ser *types.Uint40) (enc *T)
Constants ¶
const ( EventPrefix = I("evt") SmallEventPrefix = I("sev") // small event with inline data (<=384 bytes) ReplaceableEventPrefix = I("rev") // replaceable event (kinds 0,3,10000-19999) with inline data AddressableEventPrefix = I("aev") // addressable event (kinds 30000-39999) with inline data IdPrefix = I("eid") FullIdPubkeyPrefix = I("fpc") // full id, pubkey, created at CreatedAtPrefix = I("c--") // created at KindPrefix = I("kc-") // kind, created at PubkeyPrefix = I("pc-") // pubkey, created at KindPubkeyPrefix = I("kpc") // kind, pubkey, created at TagPrefix = I("tc-") // tag, created at TagKindPrefix = I("tkc") // tag, kind, created at TagPubkeyPrefix = I("tpc") // tag, pubkey, created at TagKindPubkeyPrefix = I("tkp") // tag, kind, pubkey, created at WordPrefix = I("wrd") // word hash, serial ExpirationPrefix = I("exp") // timestamp of expiration VersionPrefix = I("ver") // database version number, for triggering reindexes when new keys are added (policy is add-only). // Pubkey graph indexes PubkeySerialPrefix = I("pks") // pubkey hash -> pubkey serial SerialPubkeyPrefix = I("spk") // pubkey serial -> pubkey hash (full 32 bytes) EventPubkeyGraphPrefix = I("epg") // event serial -> pubkey serial (graph edges) PubkeyEventGraphPrefix = I("peg") // pubkey serial -> event serial (reverse edges) )
Variables ¶
var AddressableEvent = next()
AddressableEvent stores parameterized replaceable events (kinds 30000-39999) with inline data. Optimized storage for addressable events identified by pubkey+kind+d-tag. Key format enables direct lookup without additional index traversal.
prefix|8 pubkey_hash|2 kind|8 dtag_hash|2 size_uint16|data (variable length, max 384 bytes)
var CreatedAt = next()
CreatedAt is an index that allows search for the timestamp on the event.
3 prefix|8 timestamp|5 serial
var Event = next()
Event is the whole event stored in binary format
prefix|5 serial - event in binary format
var EventPubkeyGraph = next()
EventPubkeyGraph creates a bidirectional graph edge between events and pubkeys This stores event_serial -> pubkey_serial relationships with event kind and direction Direction: 0=author, 1=p-tag-out (event references pubkey)
3 prefix|5 event serial|5 pubkey serial|2 kind|1 direction
var Expiration = next()
Expiration
3 prefix|8 timestamp|5 serial
var FullIdPubkey = next()
FullIdPubkey is an index designed to enable sorting and filtering of results found via other indexes, without having to decode the event.
3 prefix|5 serial|32 ID|8 pubkey hash|8 timestamp
var Id = next()
Id contains a truncated 8-byte hash of an event index. This is the secondary key of an event, the primary key is the serial found in the Event.
3 prefix|8 ID hash|5 serial
var Kind = next()
Kind
3 prefix|2 kind|8 timestamp|5 serial
var KindPubkey = next()
KindPubkey
3 prefix|2 kind|8 pubkey hash|8 timestamp|5 serial
var Pubkey = next()
Pubkey is a composite index that allows search by pubkey filtered by timestamp.
3 prefix|8 pubkey hash|8 timestamp|5 serial
var PubkeyEventGraph = next()
PubkeyEventGraph creates the reverse edge: pubkey_serial -> event_serial with event kind and direction This enables querying all events related to a pubkey, optionally filtered by kind and direction Direction: 0=is-author, 2=p-tag-in (pubkey is referenced by event)
3 prefix|5 pubkey serial|2 kind|1 direction|5 event serial
var PubkeySerial = next()
PubkeySerial maps a pubkey hash to its unique serial number
3 prefix|8 pubkey hash|5 serial
var ReplaceableEvent = next()
ReplaceableEvent stores replaceable events (kinds 0,3,10000-19999) with inline data. Optimized storage for metadata events that are frequently replaced. Key format enables direct lookup by pubkey+kind without additional index traversal.
prefix|8 pubkey_hash|2 kind|2 size_uint16|data (variable length, max 384 bytes)
var SerialPubkey = next()
SerialPubkey maps a pubkey serial to the full 32-byte pubkey This stores the full pubkey (32 bytes) as the value, not inline
3 prefix|5 serial -> 32 byte pubkey value
var SmallEvent = next()
SmallEvent stores events <=384 bytes with inline data to avoid double lookup. This is a Reiser4-inspired optimization for small event packing. 384 bytes covers: ID(32) + Pubkey(32) + Sig(64) + basic fields + small content
prefix|5 serial|2 size_uint16|data (variable length, max 384 bytes)
var Tag = next()
Tag allows searching for a tag and filter by timestamp.
3 prefix|1 key letter|8 value hash|8 timestamp|5 serial
var TagKind = next()
TagKind
3 prefix|1 key letter|8 value hash|2 kind|8 timestamp|5 serial
var TagKindPubkey = next()
TagKindPubkey
3 prefix|1 key letter|8 value hash|2 kind|8 pubkey hash|8 bytes timestamp|5 serial
var TagPubkey = next()
TagPubkey allows searching for a pubkey, tag and timestamp.
3 prefix|1 key letter|8 value hash|8 pubkey hash|8 timestamp|5 serial
var Version = next()
Version
3 prefix|4 version
var Word = next()
Word index for tokenized search terms
3 prefix|8 word-hash|5 serial
Functions ¶
func AddressableEventVars ¶ added in v0.28.0
func EventPubkeyGraphVars ¶ added in v0.29.11
func FullIdPubkeyVars ¶
func KindPubkeyVars ¶
func PubkeyEventGraphVars ¶ added in v0.29.11
func PubkeySerialVars ¶ added in v0.29.11
func ReplaceableEventVars ¶ added in v0.28.0
func TagKindPubkeyVars ¶
func TagKindVars ¶
func TagPubkeyVars ¶
func TagVars ¶
Types ¶
type I ¶
type I string
func Prefix ¶
Prefix returns the three byte human-readable prefixes that go in front of database indexes.
type P ¶
type P struct {
// contains filtered or unexported fields
}
type T ¶
type T struct{ Encs }
T is a wrapper around an array of codec.I. The caller provides the Encs so they can then call the accessor methods of the codec.I implementation.
func AddressableEventDec ¶ added in v0.28.0
func AddressableEventEnc ¶ added in v0.28.0
func EventPubkeyGraphDec ¶ added in v0.29.11
func EventPubkeyGraphEnc ¶ added in v0.29.11
func FullIdPubkeyDec ¶
func FullIdPubkeyEnc ¶
func KindPubkeyDec ¶
func KindPubkeyEnc ¶
func New ¶
New creates a new indexes.T. The helper functions below have an encode and decode variant, the decode variant doesn't add the prefix encoder because it has been read by Identify or just is being read, and found because it was written for the prefix in the iteration.
func PubkeyEventGraphDec ¶ added in v0.29.11
func PubkeyEventGraphEnc ¶ added in v0.29.11
func PubkeySerialDec ¶ added in v0.29.11
func PubkeySerialEnc ¶ added in v0.29.11
func ReplaceableEventDec ¶ added in v0.28.0
func ReplaceableEventEnc ¶ added in v0.28.0
func TagDec ¶
func TagEnc ¶
func TagKindDec ¶
func TagKindEnc ¶
func TagKindPubkeyDec ¶
func TagKindPubkeyEnc ¶
func TagPubkeyDec ¶
func TagPubkeyEnc ¶
Source Files
¶
- keys.go