upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/components/wisp_relay/relay_validator.h
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-19 02:31:19 +0530
committerYour Name <you@example.com>2026-05-19 02:32:41 +0530
commit81f2dc52dc42d01c89dff45a5407ec40b8863052 (patch)
tree15018c2438639ca89dc6d33a5144c10d0b1c2af0 /components/wisp_relay/relay_validator.h
parent75688d55b3c8d13c8c9a50da9668ec408f684cb3 (diff)
feat: local Nostr relay with relay selection, sync, and integration tests
Local Nostr relay (NIP-01) on port 4869 with LittleFS 4MB storage. All events published locally first, then synced to public relays via REQ-diff. Relay selection via NIP-11 HTTP probing with NIP-77 scoring and auto-failover. Components: - wisp_relay: 16-file local relay (ws_server, storage_engine, sub_manager, broadcaster, relay_validator, router, handlers, rate_limiter, nip11, deletion, flash_monitor, relay_types) - esp_littlefs: LittleFS VFS integration (git submodule) - negentropy: for future NIP-77 binary sync (git submodule) New source files: - local_relay.c/h: thin wrapper for relay init/start/publish - relay_selector.c/h: NIP-11 probe + scoring + auto-failover - sync_manager.c/h: REQ-diff sync (primary 30min, fallback 6h) Bug fixes: - config.c: use-after-free (cJSON_Delete before seed_relays/sync parsing) - local_relay: moved init to app_main for boot-time start (not gated on STA IP) Flash layout: 4MB LittleFS partition at 0x500000 for relay_store Test results (Board B, live hardware): - Smoke: ping + HTTP 4869 + NIP-11: PASS - NIP-11 info document: 10/11 PASS - WS pub/sub (connect, REQ/EOSE, EVENT/OK, CLOSE, concurrent): 6/6 PASS - Unit tests (relay_validator + relay_selector): 13/13 PASS Hardware test make targets in physical-router-test-automation/: - make relay-build, relay-flash-b, relay-test-smoke/nip11/pubsub/sync/full
Diffstat (limited to 'components/wisp_relay/relay_validator.h')
-rw-r--r--components/wisp_relay/relay_validator.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/components/wisp_relay/relay_validator.h b/components/wisp_relay/relay_validator.h
new file mode 100644
index 0000000..c07308f
--- /dev/null
+++ b/components/wisp_relay/relay_validator.h
@@ -0,0 +1,45 @@
1#ifndef RELAY_VALIDATOR_H
2#define RELAY_VALIDATOR_H
3
4#include <stdint.h>
5#include <stdbool.h>
6#include <stddef.h>
7
8typedef enum {
9 VALIDATION_OK = 0,
10 VALIDATION_ERR_SCHEMA,
11 VALIDATION_ERR_ID,
12 VALIDATION_ERR_SIG,
13 VALIDATION_ERR_EXPIRED,
14 VALIDATION_ERR_FUTURE,
15 VALIDATION_ERR_DUPLICATE,
16 VALIDATION_ERR_POW,
17 VALIDATION_ERR_BLOCKED,
18 VALIDATION_ERR_TOO_OLD,
19} validation_result_t;
20
21typedef struct {
22 uint32_t max_event_age_sec;
23 int64_t max_future_sec;
24 uint8_t min_pow_difficulty;
25 bool check_duplicates;
26} validator_config_t;
27
28typedef struct relay_event relay_event_t;
29typedef struct storage_engine storage_engine_t;
30
31validation_result_t relay_validator_check(const uint8_t *id,
32 const uint8_t *pubkey,
33 uint64_t created_at,
34 int kind,
35 const char *content,
36 size_t content_len,
37 const char *tags_json,
38 const uint8_t *sig,
39 const validator_config_t *config);
40
41bool relay_validator_verify_event(const char *event_json, size_t event_len);
42
43const char *relay_validator_result_string(validation_result_t result);
44
45#endif