67 Commits

Author SHA1 Message Date
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
c9411a3c5b depressing sonic json decoder implementation, breakingly force COUNT to use a single filter, reorganize envelope tests. 2025-03-06 19:34:36 -03:00
fiatjaf
5bfaed2740 docstrings for many functions. 2025-03-04 11:42:44 -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
0d40b40c9c pool: support CountMany() using hyperloglog. 2024-11-16 17:47:42 -03:00
fiatjaf
9c692af624 I think this handles CLOSED messages better. 2024-10-16 16:27:50 -03:00
fiatjaf
9e0a86d48e subscription must be deemed closed when receiving a CLOSED. 2024-10-15 18:27: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
7503643e80 stop debuglogging duplicate "sending" messages, that has confused me absurdly. 2024-09-26 21:12:19 -03:00
fiatjaf
f57d93ac78 after getting an EOSE we should stop checking since/until. 2024-09-06 19:37:34 -03:00
fiatjaf
5938a71146 replace close() with actually sending a value to .EndOfStoredEvents and .Closed channels.
I thought `close()` would be nice because it would be cheap and not lock the goroutine while waiting for the receiver to acknowledge the thing, but turns out it introduces the serious risk of users putting <- sub.EndOfStoredEvents in the same for { select {} } statement as sub.Events, for example, and they they get into an infinite loop.

we had this same problem here inside this same library, and what is fixed in 242af0bf76e4b23de47012244efb95ccec9e4374 by @mattn.
2024-01-01 10:18:16 -03:00
fiatjaf
7449f254db
support handling CLOSED messages from relay client. 2023-11-28 18:54:24 -03:00
fiatjaf
1f605f3629
remove intermediary .events channel and hacky ms sleep. 2023-09-04 08:57:53 -03:00
fiatjaf
6d1875de46
ensure eose channel closes after events have been emitted. 2023-09-04 08:33:31 -03:00
fiatjaf
446b104990
simplify subscription closing. 2023-08-22 10:58:34 -03:00
fiatjaf
c5bf5892c3
release sub.Events lock when subscription is canceled. 2023-08-21 15:53:27 -03:00
Kay
ac2350c722 style: using effective go and refactoring 2023-08-21 15:50:05 -03:00
fiatjaf
53b9dde6e0
relay.Count() 2023-07-18 16:17:00 -03:00
fiatjaf
6cee628149
rename debugLog->debugLogf 2023-07-11 15:25:02 -03:00
fiatjaf
71f4594033
wait when CLOSEing. 2023-06-25 12:56:17 -03:00
fiatjaf
54d3de4908 refactor some things, add back one mutex for each subscription for dispatching events, but in a cleaner way. 2023-06-25 00:17:39 -03:00
fiatjaf
ac0c0769fe
disentangle things a little more.
having a single loop for everything was too much. goroutines things were getting stuck.
2023-06-23 16:23:00 -03:00
fiatjaf
f0a35d7ab2
Write returns an error in a channel (why? I think it makes no difference.) 2023-06-22 10:46:31 -03:00
fiatjaf
68648a16b9
remove conn field from subscription. 2023-06-22 09:12:35 -03:00
fiatjaf
030c1d1898
get rid of mutexes and use a single loop to prevent races.
in the meantime change the API to makes a little less error-prone.
2023-06-21 19:55:43 -03:00
Isaque Veras
58d56abe05 fix: removing redundancy 2023-06-12 08:18:29 -03:00
fiatjaf
bc783a3a24
fix atomicity of subscription ids. 2023-06-09 11:01:42 -03:00
fiatjaf
a2941876e3
expose subscriptions from relay and keep that updated. 2023-05-30 14:55:44 -03:00
fiatjaf
0f7a3f01f2
use an atomic counter. 2023-05-30 14:01:07 -03:00
fiatjaf
9dc674bc02
use different contexts for the relay connection lifetime and the Connect() call.
fixes https://github.com/nbd-wtf/go-nostr/pull/86
2023-05-09 17:08:08 -03:00
fiatjaf
ccbb44989f
get rid of WriteJSON() and replace calls with manually marshaled envelopes. 2023-05-09 17:02:22 -03:00
fiatjaf
326d2790de
rename interface{} to any. 2023-04-12 12:14:24 -03:00
fiatjaf
ec3f1287c4
debug log CLOSE messages. 2023-04-12 12:14:16 -03:00
fiatjaf
6f74d284c4
improved logging thing with the "debug" build tag. 2023-04-11 09:35:37 -03:00
fiatjaf
4507477486
slight improvements to debug logging. 2023-04-11 07:10:05 -03:00
fiatjaf
e103c99bb8
a pluggable logging interface and more debug logging. 2023-04-11 00:32:32 -03:00
fiatjaf
ef428ff39f
Subscription.Fire() can error, so Relay.Subscribe() must also. 2023-04-06 16:21:25 -03:00
fiatjaf
4b1f69ec27
subscriptions receive their context on Prepare(). 2023-03-21 14:50:34 -03:00
fiatjaf
46e724b8d5
dry sub.unsub() on context cancelation. 2023-03-18 16:07:19 -03:00
fiatjaf
85fc74fd22
fixing subscription labels and ids. 2023-03-18 15:09:49 -03:00
fiatjaf
3f66c60b5f
subscription labels: GetID() and SetLabel(). 2023-03-18 08:40:12 -03:00
fiatjaf
fdc99d61b6
subscription ids as sequential numbers and sub.GetID() 2023-03-17 16:43:48 -03:00
fiatjaf
0765f7b91b
context cancelation for relay connections and subscriptions. 2023-03-16 14:16:46 -03:00
fiatjaf
92c0143762
make sub.Events a channel of pointers. 2023-01-26 09:04:27 -03:00
barkyq
87b6280299
Added some NIP-42 functionality to the client (relay.go) (#38) 2023-01-16 08:27:11 -03:00