diff options
| author | bndw <ben@bdw.to> | 2026-03-09 08:01:02 -0700 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-03-09 08:01:02 -0700 |
| commit | 61a85baf87d89fcc09f9469a113a2ddc982b0a24 (patch) | |
| tree | d8359ce5cbcbb9402ba92c617c4ebd702adf33e9 /axon.go | |
| parent | ce684848e25fed3aabdde4ffba6d2d8c40afa030 (diff) | |
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)
Diffstat (limited to 'axon.go')
| -rw-r--r-- | axon.go | 22 |
1 files changed, 22 insertions, 0 deletions
| @@ -29,6 +29,28 @@ type Tag struct { | |||
| 29 | Values []string `msgpack:"values" json:"values"` | 29 | Values []string `msgpack:"values" json:"values"` |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | // TagFilter selects events that have a tag with the given name and any of the | ||
| 33 | // given values. An empty Values slice matches any value. | ||
| 34 | type TagFilter struct { | ||
| 35 | Name string `msgpack:"name"` | ||
| 36 | Values []string `msgpack:"values"` | ||
| 37 | } | ||
| 38 | |||
| 39 | // Filter selects a subset of events. All non-empty fields are ANDed together; | ||
| 40 | // multiple entries within a slice field are ORed. | ||
| 41 | // | ||
| 42 | // IDs and Authors support prefix matching: a []byte shorter than 32 bytes | ||
| 43 | // matches any event whose ID (or pubkey) starts with those bytes. | ||
| 44 | type Filter struct { | ||
| 45 | IDs [][]byte `msgpack:"ids"` | ||
| 46 | Authors [][]byte `msgpack:"authors"` | ||
| 47 | Kinds []uint16 `msgpack:"kinds"` | ||
| 48 | Since int64 `msgpack:"since"` // inclusive lower bound on created_at | ||
| 49 | Until int64 `msgpack:"until"` // inclusive upper bound on created_at | ||
| 50 | Limit int32 `msgpack:"limit"` // max events to return (0 = no limit) | ||
| 51 | Tags []TagFilter `msgpack:"tags"` | ||
| 52 | } | ||
| 53 | |||
| 32 | // Event is the core Axon data structure. All fields use their wire types. | 54 | // Event is the core Axon data structure. All fields use their wire types. |
| 33 | // id, pubkey and sig are raw 32/64-byte slices, not hex. | 55 | // id, pubkey and sig are raw 32/64-byte slices, not hex. |
| 34 | // content is opaque bytes (msgpack bin type). | 56 | // content is opaque bytes (msgpack bin type). |
