Commit Graph

147 Commits

Author SHA1 Message Date
fiatjaf
83c34daa8b OK callbacks that still work even if the same event is published twice. 2025-07-30 15:06:30 -03:00
fiatjaf
6592319774 stop exposing connection, more debugLog calls and properly fail subscriptions when a relay dies. 2025-07-13 14:21:15 -03:00
fiatjaf
9f8b810882 fix main relay context being canceled instead of just the dial context. 2025-07-11 13:01:04 -03:00
fiatjaf
7289da9c72 improve/refactor websocket connections hoping this will fix the undetected disconnections we're seeing.
this commit also remove all the sonic envelope parsing and reintroduces filters in REQ as a slice instead of as a singleton.

why? well, the sonic stuff wasn't really that fast, it was a little bit but only got fast enough once I introduced unsafe conversions between []byte and string and did weird unsafe reuse of []byte in order to save the values of tags, which would definitely cause issues in the future if the caller wasn't aware of it (and even if they were, like myself).

and the filters stuff is because we abandoned the idea of changing NIP-01 to only accept one filter per REQ.
2025-07-10 22:58:37 -03:00
fiatjaf
28f85c9ea3 fix sending request header. 2025-05-30 10:09:03 -03:00
pippellia-btc
0853405c03 probably fixing race condition. 2025-05-07 10:34:05 -03:00
fiatjaf
15c6093c9b define a nostr.Kind type for event kinds, make adjustments everywhere and fix some horrible bugs with mmm, lmdb and badger querying and deleting. 2025-04-20 11:15:41 -03:00
fiatjaf
f7884cea4f wait, Querier can just return an iter like eventstore, it's ok. 2025-04-16 03:06:27 -03:00
fiatjaf
5b8954461f it never ends. 2025-04-16 02:59:47 -03:00
fiatjaf
2b5b646a62 a big bundle of conversions and other changes. 2025-04-15 17:13:57 -03:00
fiatjaf
b4268d649c a bunch of [32]byte conversions. still more needed. 2025-04-14 17:47:53 -03:00
fiatjaf
dad99b226c relay: fix unsafe overwriting of event buffer that affected parsed pubkeys, ids, content. 2025-04-07 15:56:36 -03:00
fiatjaf
cc23d81e80 pool's .FetchManyReplaceable() and amends to previous commit. 2025-03-12 00:49:58 -03:00
fiatjaf
441f94563f WithCheckDuplicateReplaceable() and helper functions for efficient replaceable event matching. 2025-03-12 00:19:41 -03:00
fiatjaf
cecc71cd81 fix and improve envelope stuff again, deal with messages as strings on all envelope parsing steps. 2025-03-12 00:18:11 -03:00
fiatjaf
5bfaed2740 docstrings for many functions. 2025-03-04 11:42:44 -03:00
fiatjaf
17431dee59 do not close relay connection when ping fails because some relays just do not pong. 2025-01-25 00:26:38 -03:00
fiatjaf
3e1c0ddc7e fix pinging relays: use the main relay context, not the relay connection temporary context. 2025-01-17 14:08:54 -03:00
fiatjaf
06a15fdaab follow list fetching test and related changes and fixes.
- make BatchedSubManyEose() use a single duplicate id index and use it for replaceable loaders;
- fixes parsing follow entry from kind:3 events (and others);
- adds a "cause" to most cancelation errors in relay/pool;
- remove the inherent cache from dataloader (we have our own hopefully);
- increase max frame size we can read from any websocket to 2**18 (262k), which gives over 2000 item lists.
2025-01-17 13:44:51 -03:00
fiatjaf
febf022124 add some basic sdk tests, fix saving hints (normalize urls), checkduplicates arg order, kvdb stuff and other things. 2025-01-16 17:39:16 -03:00
fiatjaf
e1971d12c0 WithCheckDuplicate(), let's see if this works. 2025-01-15 14:29:38 -03:00
fiatjaf
795f9516ae use @mmalmi json string preparsing speedup for duplicate events
- get rid of "nonUnique" variants of subMany as we can now relay on CheckDuplicate to track relays.
- add global pool tracker duplicateMiddleware.
2025-01-15 14:29:38 -03:00
fiatjaf
defc349e57 use coder/websocket for everything, get rid of gobwas.
supposedly it is faster, and anyway it's better to use it since we're already using it for wasm/js.

(previously named nhooyr/websocket).
2025-01-03 01:15:17 -03:00
reis
63919cf685 support wasm (#163) 2025-01-02 09:42:04 -03:00
fiatjaf
f22d4b7692 make it clear that a message was _received_ from a given relay on log output. 2024-12-17 11:06:36 -03:00
fiatjaf
1106329c95 return hyperloglog value from Relay.Count() 2024-12-10 23:24:45 -03:00
fiatjaf
851116d2e3 Merge branch 'hyperloglog' 2024-12-07 00:13:23 -03:00
fiatjaf
98d3766474 fix race condition on ticker ping.
fixes nevent1qqszqakrmmjyjelgp06f3hx0fu70xyvmqt4ed8v65xpmpy9g8nj9qgqpz4mhxue69uhkummnw3ezummcw3ezuer9wchsz9nhwden5te0dehhxarjv4kxjar9wvhx7un89uq32amnwvaz7tmjv4kxz7fwv3sk6atn9e5k7tcnynjra
2024-11-24 14:49:32 -03:00
fiatjaf
0d40b40c9c pool: support CountMany() using hyperloglog. 2024-11-16 17:47:42 -03:00
fiatjaf
4cf3cdbe66 fix horrible infinite loop in Relay.QueryEvents() 2024-10-18 07:07:53 -03:00
fiatjaf
9e0a86d48e subscription must be deemed closed when receiving a CLOSED. 2024-10-15 18:27:19 -03:00
fiatjaf
fe3508881b in the last commits we had forgotten to handle the case in which there was no WithLabel(). 2024-09-29 17:02:19 -03:00
fiatjaf
ad14daec9f allocate subscription id only once on creation. 2024-09-29 16:44:31 -03:00
fiatjaf
24343dbbef reduce allocations at subscription.GetID() because why not. 2024-09-29 07:55:06 -03:00
fiatjaf
47d493b7e8 make libsecp256k1 available with a build tag. 2024-09-27 17:45:46 -03:00
fiatjaf
0caf8deb56 WithUserAgent() pool option. 2024-09-26 19:18:34 -03:00
fiatjaf
23ddac33dd hopefully fix a segfault with broken connections. 2024-09-20 22:59:31 -03:00
fiatjaf
515f76bd86 add a default user-agent: github.com/nbd-wtf/go-nostr.
fixes https://github.com/nbd-wtf/go-nostr/issues/147
2024-09-16 07:11:19 -03:00
fiatjaf
a094f3a9d2 negentropy.
- a way to handle custom messages from Relay (NEG-whatever etc)
- negentropy implementation (adapted from that other one)
- nip77 nostr negentropy extension
- QueryEvents method for RelayStore that returns a channel (makes negentropy syncing work more seamlessly)
2024-09-14 07:40:09 -03:00
fiatjaf
9addd57db7 missing bit from f57d93. 2024-09-11 10:16:28 -03:00
fiatjaf
f57d93ac78 after getting an EOSE we should stop checking since/until. 2024-09-06 19:37:34 -03:00
fiatjaf
51e527680e WithNoticeHandler() just calls a function, no channel stuff anymore.
probably fixes https://t.me/nostr_protocol/145832

I think we were using this channel for legacy reasons, it feels completely unnecessary now.
2024-08-31 23:12:20 -03:00
fiatjaf
a7303c385b error instead of panic'ing when opening subscription. 2024-06-27 14:50:24 -03:00
fiatjaf
a35cdff6c8 problem: connection can be nil when writing and we're panic'ing. 2024-06-21 09:32:53 -03:00
fiatjaf
37ef70e4cb relay: prevent panic on double-closing.
probably fixes https://github.com/nbd-wtf/go-nostr/issues/130
2024-06-19 09:59:28 -03:00
fiatjaf
d06f61136d allow using libsecp256k1 for signature verification in subscriptions. 2024-05-29 17:08:15 -03:00
ice-cronus
c0f1c4f510 add option to connect with custom TLS 2024-03-28 15:54:12 -03:00
fiatjaf
09ea5d5758 subscription.EndOfStoredEvents to have a capacity of 1 so it never gets deadlocked. 2024-01-28 14:34:05 -03:00
fiatjaf
7b292775c0 migrate to xsync/v3
closes https://github.com/nbd-wtf/go-nostr/issues/117
2024-01-10 06:54:53 -03:00
fiatjaf
3e1749a01d fix OK handling. 2023-12-09 13:21:35 -03:00