Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Return 2 separate parameters in onnotice() or onerror() #18

Closed
chmac opened this issue Jan 15, 2023 · 10 comments
Closed

Suggestion: Return 2 separate parameters in onnotice() or onerror() #18

chmac opened this issue Jan 15, 2023 · 10 comments

Comments

@chmac
Copy link

chmac commented Jan 15, 2023

Looking at the API in README and the code, it looks like you concatenate the relay (presumably the relay URL) and error or notice params with a colon.

I imagine that I want to know which relay generated which notices, so I can tell the user "this relay sent this X". Of course I could extract it from the string, but it's a bit more complicated to get just the error out of a string like this: wss://foo:error_with_colon:second_message.

I'd imagine something like (relay: string, message: string) => void as a signature.

@adamritter
Copy link
Owner

adamritter commented Jan 15, 2023 via email

@chmac
Copy link
Author

chmac commented Jan 16, 2023

Haha! I wanted to use your relaypool implementation, but the caching stuff was a bit too opaque for me to easily understand. I ended up writing a thin layer over redux instead. The filter deduplication stuff you've written is a nice idea, I had similar thoughts. I found the code impossible to understand, plus I'm a bit wary of let although I admit that's just a prejudice on my part! Anyway, all of that means I'm not using the codebase so I won't submit a PR. Just wanted to share the suggestion in case you think it's useful.

@adamritter
Copy link
Owner

adamritter commented Jan 16, 2023 via email

@chmac
Copy link
Author

chmac commented Jan 16, 2023

I appreciate you being open to feedback. It's not always the case!

I also hear you on everyone reinventing the wheel. It's helpful to have something like nostr-tools which seems to be a standard.

I'm happy to have a closer look at the code and open some issues if you like. For example I just looked at relay.ts and it seems like it's the same or similar to relay.ts in nostr-tools. Maybe there's a good reason for having it in there? An explanation as a comment at the top of the file might make that knowledge more accessible.

In general I'm a big fan of comments. Lots of them. I loved literate coffeescript where you write markdown files and the indented code blocks get executed, more comments than code!

Trying to read relay-pool, my mind is breaking! I think one of the biggest issues is the code formatting. Have you considered using prettier? I'm so used to prettier output by now, that personally, I struggle to read code properly without it. When I copy and paste the file into my editor and format it, I get a lot further.

There seems to be a ton of functionality in that one file. I wonder if there's a way to break it into smaller parts which are individually easier to understand?

The readme could also be a lot simpler to read. More headings, even just more formatting like code blocks on variable names and so on would make it easier to parse.

My sense is that the nostr space is pretty chaotic at the moment. I guess it'll take a bit of time for that to settle down. My advice for nostr-relaypool would be to work on the docs and simplifying the explanation of what it does. It seems like there's a ton of features in there. Like aggregating filters, sending subscriptions to specific relays, caching results, logic to handle different replaceable events, and so on. But I can't tell how much of which of those things works properly and overlaps. Like what happens if multiple relays return different nip33 events? I think I'd only be able to figure that out by testing, I don't think I'd be able to answer that by reading the code.

@adamritter
Copy link
Owner

adamritter commented Jan 16, 2023 via email

@adamritter
Copy link
Owner

adamritter commented Jan 16, 2023 via email

@adamritter
Copy link
Owner

adamritter commented Jan 16, 2023 via email

@adamritter
Copy link
Owner

adamritter commented Jan 16, 2023 via email

@adamritter
Copy link
Owner

@chmac Hi, I implemented this issue, still it would be nice to talk more, the feedback you provided was appreciated. You can reach me on Telegram as well @Adam8812

@chmac
Copy link
Author

chmac commented Jan 18, 2023

Cool, awesome to see so many updates. I'll ping you now on telegram, I'm also @chmac on there.

I'll look at the new version now and share any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants