event

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	ID        string     `bson:"id"         json:"id"`
	PublicKey string     `bson:"pubkey"     json:"pubkey"`
	CreatedAt int64      `bson:"created_at" json:"created_at"`
	Kind      types.Kind `bson:"kind"       json:"kind"`
	Tags      types.Tags `bson:"tags"       json:"tags"`
	Content   string     `bson:"content"    json:"content"`
	Signature string     `bson:"sig"        json:"sig"`
}

Event represents an event structure defined on NIP-01.

func Decode

func Decode(b []byte) (*Event, error)

Decode decodes a byte array into Event structure.

func (*Event) Difficulty added in v0.0.5

func (e *Event) Difficulty() int

Difficulty returns the leading zeros of event id in base-2.

func (*Event) Encode

func (e *Event) Encode() ([]byte, error)

Encode encodes an Event to a byte array.

func (*Event) GetRawID

func (e *Event) GetRawID() [32]byte

GetID calculates ID of a given event.

func (*Event) IsProtected added in v0.0.5

func (e *Event) IsProtected() bool

IsProtected checks is ["-"] is present, look nip-70 for more.

func (*Event) IsValid

func (e *Event) IsValid(id [32]byte) bool

IsValid function validats an event Signature and ID.

func (Event) MarshalEasyJSON

func (e Event) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface.

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface.

func (*Event) Serialize

func (e *Event) Serialize() []byte

func (*Event) String

func (e *Event) String() string

String returns and encoded string representation of event e.

func (*Event) UnmarshalEasyJSON

func (e *Event) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface.

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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