Why Nostr? What is Njump?
2024-08-29 21:17:24

mleku on Nostr: so i finally have figured out how i'm supposed to do this websocket ...

so i finally have figured out how i'm supposed to do this websocket listener/subscription thing

already wrote most of it, just haven't plugged in the actual handlers to add the filters properly or when events arrive, to scan the events to find the sockets to fire them off to

i think i might manage to get it working tomorrow

it's all in the "listener.go" in relayer, which i remember being much similar in the khatru version except relayer doesn't use the fancy xsync maps

my implementation also just uses a normal mutex, the different feature i'm adding is the filters get fingerprinted so if clients send them repeatedly the filter only has to be tested for matches once and then iterate the listeners to find the matching filter fingerprint for the websocket to send it to

which i think is a bit more efficient when you scale it up and have to deal with dumbass clients that might send out the same stupid filter while it is already active, and even can deduplicate when multiple clients are watching for events from the same npub or whatever, it doesn't match on each of them, just the common one and then just iterate the subscribers list to send em

it's not obvious at small scale but i'm well wary of how dumb clients can be

will be a big smile on my face when the relay actually works with a client tho... right now it just passes all the relay tester tests that don't depend on subscriptions, so that will be first thing to get done

#thoon
Author Public Key
npub1fjqqy4a93z5zsjwsfxqhc2764kvykfdyttvldkkkdera8dr78vhsmmleku