From 61a85baf87d89fcc09f9469a113a2ddc982b0a24 Mon Sep 17 00:00:00 2001 From: bndw Date: Mon, 9 Mar 2026 08:01:02 -0700 Subject: feat: phase 2 relay implementation Implement the Axon relay as relay/ (module axon/relay). Includes: - WebSocket framing (RFC 6455, no external deps) in relay/websocket/ - Per-connection auth: challenge/response with ed25519 + allowlist check - Ingest pipeline: sig verify, dedup, ephemeral fanout, SQLite persistence - Subscription manager with prefix-matching filter fanout in relay/subscription/ - SQLite storage with WAL/cache config and UNION query builder in relay/storage/ - Graceful shutdown on SIGINT/SIGTERM - Filter/TagFilter types added to axon core package (required by relay) --- axon.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'axon.go') diff --git a/axon.go b/axon.go index 51ec22d..ebe18a2 100644 --- a/axon.go +++ b/axon.go @@ -29,6 +29,28 @@ type Tag struct { Values []string `msgpack:"values" json:"values"` } +// TagFilter selects events that have a tag with the given name and any of the +// given values. An empty Values slice matches any value. +type TagFilter struct { + Name string `msgpack:"name"` + Values []string `msgpack:"values"` +} + +// Filter selects a subset of events. All non-empty fields are ANDed together; +// multiple entries within a slice field are ORed. +// +// IDs and Authors support prefix matching: a []byte shorter than 32 bytes +// matches any event whose ID (or pubkey) starts with those bytes. +type Filter struct { + IDs [][]byte `msgpack:"ids"` + Authors [][]byte `msgpack:"authors"` + Kinds []uint16 `msgpack:"kinds"` + Since int64 `msgpack:"since"` // inclusive lower bound on created_at + Until int64 `msgpack:"until"` // inclusive upper bound on created_at + Limit int32 `msgpack:"limit"` // max events to return (0 = no limit) + Tags []TagFilter `msgpack:"tags"` +} + // Event is the core Axon data structure. All fields use their wire types. // id, pubkey and sig are raw 32/64-byte slices, not hex. // content is opaque bytes (msgpack bin type). -- cgit v1.2.3