index

package
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2024 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Len = 1

Variables

View Source
var FilterPrefixes = [][]byte{
	{CreatedAt.B()},
	{Id.B()},
	{Kind.B()},
	{Pubkey.B()},
	{PubkeyKind.B()},
	{Tag.B()},
	{Tag32.B()},
	{TagAddr.B()},
}

FilterPrefixes is a slice of the prefixes used by filter index to enable a loop for pulling events matching a serial

KeySizes are the byte size of keys of each type of key prefix. int(P) or call the P.I() method corresponds to the index 1:1. For future index additions be sure to add the relevant KeySizes sum as it describes the data for a programmer.

Functions

func GetAsBytes

func GetAsBytes(prf ...P) (b [][]byte)

GetAsBytes todo wat is dis?

Types

type B

type B = []byte

type Ctx

type Ctx = context.T

type E

type E = error

type N

type N = int

type P

type P byte
const (
	// Event is the prefix used with a Serial counter value provided by badgerDB to
	// provide conflict-free 8 byte 64-bit unique keys for event records, which
	// follows the prefix.
	//
	//   [ 0 ][ 8 bytes Serial ]
	Event P = iota

	// CreatedAt creates an index key that contains the unix
	// timestamp of the event record serial.
	//
	//   [ 1 ][ 8 bytes timestamp.T ][ 8 bytes Serial ]
	CreatedAt

	// Id contains the first 8 bytes of the ID of the event and the 8
	// byte Serial of the event record.
	//
	//   [ 2 ][ 8 bytes eventid.T prefix ][ 8 bytes Serial ]
	Id

	// Kind contains the kind and datestamp.
	//
	//   [ 3 ][ 2 bytes kind.T ][ 8 bytes timestamp.T ][ 8 bytes Serial ]
	Kind

	// Pubkey contains pubkey prefix and timestamp.
	//
	//   [ 4 ][ 8 bytes pubkey prefix ][ 8 bytes timestamp.T ][ 8 bytes Serial ]
	Pubkey

	// PubkeyKind contains pubkey prefix, kind and timestamp.
	//
	//   [ 5 ][ 8 bytes pubkey prefix ][ 2 bytes kind.T ][ 8 bytes timestamp.T ][ 8 bytes Serial ]
	PubkeyKind

	// Tag is for miscellaneous arbitrary length tags, with timestamp and event
	// serial after.
	//
	//   [ 6 ][ tag string 1 <= 100 bytes ][ 8 bytes timestamp.T ][ 8 bytes Serial ]
	Tag

	// Tag32 contains the 8 byte pubkey prefix, timestamp and serial.
	//
	//   [ 7 ][ 8 bytes pubkey prefix ][ 8 bytes timestamp.T ][ 8 bytes Serial ]
	Tag32

	// TagAddr contains the kind, pubkey prefix, value (index 2) of address tag (eg
	// relay address), followed by timestamp and serial.
	//
	//   [ 8 ][ 2 byte kind.T][ 8 byte pubkey prefix ][ network address ][ 8 byte timestamp.T ][ 8 byte Serial ]
	TagAddr

	// Counter is the eventid.T prefix, value stores the average time of access
	// (average of all access timestamps) and the size of the record.
	//
	//   [ 9 ][ 8 bytes Serial ] : value: [ 8 bytes timestamp ]
	Counter

	// Tombstone is an index that contains the left half of an event ID that has
	// been deleted. The purpose of this event is to stop the event being
	// republished, as a delete event may not be respected by other relays and
	// eventually lead to a republication. The timestamp is added at the end to
	// enable pruning the oldest tombstones.
	//
	// [ 10 ][ 16 bytes first/left half of event ID ][ 8 bytes timestamp ]
	Tombstone
)
const (
	// Version is the key that stores the version number, the value is a 16-bit
	// integer (2 bytes)
	//
	//   [ 255 ][ 2 byte/16 bit version code ]
	Version P = 255
)

func (P) B

func (p P) B() byte

B returns the index.P as a byte.

func (P) I

func (p P) I() int

I returns the index.P as an int (for use with the KeySizes.

func (P) Key

func (p P) Key(element ...keys.Element) (b []byte)

Key writes a key with the P prefix byte and an arbitrary list of keys.Element.

type S

type S = string

type T

type T struct {
	Val []byte
}

func Empty

func Empty() (p *T)

func New

func New[V byte | P | int](code ...V) (p *T)

func (*T) Len

func (p *T) Len() int

func (*T) Read

func (p *T) Read(buf *bytes.Buffer) (el keys.Element)

func (*T) Write

func (p *T) Write(buf *bytes.Buffer)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL