Add core packages, configuration system, and initial application structure

This commit is contained in:
2025-08-21 11:04:03 +01:00
parent b8db587d7b
commit ecaf52b98f
18 changed files with 12889 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
package event
// E is the primary datatype of nostr. This is the form of the structure that
// defines its JSON string-based format.
type E struct {
// ID is the SHA256 hash of the canonical encoding of the event in binary format
ID []byte
// Pubkey is the public key of the event creator in binary format
Pubkey []byte
// CreatedAt is the UNIX timestamp of the event according to the event
// creator (never trust a timestamp!)
CreatedAt int64
// Kind is the nostr protocol code for the type of event. See kind.T
Kind uint16
// Tags are a list of tags, which are a list of strings usually structured
// as a 3-layer scheme indicating specific features of an event.
Tags [][]byte
// Content is an arbitrary string that can contain anything, but usually
// conforming to a specification relating to the Kind and the Tags.
Content []byte
// Sig is the signature on the ID hash that validates as coming from the
// Pubkey in binary format.
Sig []byte
}
// S is an array of event.E that sorts in reverse chronological order.
type S []*E
// Len returns the length of the event.Es.
func (ev S) Len() int { return len(ev) }
// Less returns whether the first is newer than the second (larger unix
// timestamp).
func (ev S) Less(i, j int) bool { return ev[i].CreatedAt > ev[j].CreatedAt }
// Swap two indexes of the event.Es with each other.
func (ev S) Swap(i, j int) { ev[i], ev[j] = ev[j], ev[i] }
// C is a channel that carries event.E.
type C chan *E

View File

@@ -0,0 +1,10 @@
// Package examples is an embedded jsonl format of a collection of events
// intended to be used to test an event codec.
package examples
import (
_ "embed"
)
//go:embed out.jsonl
var Cache []byte

File diff suppressed because one or more lines are too long