mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-11 08:47:33 +00:00
BasicRelayClient's decode step becomes a pluggable MessageDecoder (default unchanged). The opt-in CachingEventDecoder scans EVENT frames for their id (~0.3us, JSON-escape-safe so embedded event JSON in repost content cannot confuse it; any irregularity falls back to full parse) and on a cache hit synthesizes the EventMessage from the already-parsed Event with the frame's own subId — every subscription still gets its delivery and per-relay bookkeeping is unchanged; only the redundant parse is skipped. Production traffic measured 14-57% duplicate frames. DedupDecodeBenchmark (60k frames, 67% dups): 10.0us/frame full parse vs 1.5us/frame cached — 6.5x, with an in-benchmark assertion so the gain is enforced. 7 scan-safety unit tests in CachingEventDecoderTest. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018saXqYfAa3RvSJoDXK591R