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

Change accept event return type #10

Open
arejula27 opened this issue Dec 17, 2022 · 9 comments
Open

Change accept event return type #10

arejula27 opened this issue Dec 17, 2022 · 9 comments

Comments

@arejula27
Copy link

Currently the onAccept event returns a Boolean. What about changing it type to error or some new type. This could help implement nip20.

@arejula27
Copy link
Author

Maybe creating a new type "Command result" will be more correct. If u agree I can do it.

@fiatjaf
Copy link
Owner

fiatjaf commented Dec 18, 2022

Let me do it myself, I'll look at this better.

@arejula27
Copy link
Author

Well, if u need help with something just assign me some issues and I will try when have time available 👌

@katsucodes247
Copy link
Contributor

katsucodes247 commented Dec 23, 2022

I just came across this issue after opening a PR: #13

I see that there are still a few places in handlers.go where we return a message via s.WriteJSON([]interface{}{"OK", evt.ID, false, ... perhaps I should refactor that code (within my PR) to return that custom error in CheckSignature and DeleteEvent (somewhere else?) and handle it similarly as I handle it here.

Note that I'm not programming in go often so if my code it shit and this should be done differently, let me know on my PR.

@katsucodes247
Copy link
Contributor

katsucodes247 commented Dec 23, 2022

Ah, I see that CheckSignature and DeleteEvent are func in nbd-wtf lib. Would it make sense to move the errors.go code from this PR into nbd-wtf?

@arejula27
Copy link
Author

How is going?

@fiatjaf
Copy link
Owner

fiatjaf commented Dec 31, 2022

I am confused.

@arejula27
Copy link
Author

arejula27 commented Dec 31, 2022

need help?

@barkyq
Copy link
Contributor

barkyq commented Jan 18, 2023

agreed that:
(r *Relay) AcceptEvent(*nostr.Event) bool
could be changed to
(r *Relay) AcceptEvent(*nostr.Event) error
in interfaces.go, to allow for better messaging of why the event was not accepted (e.g., duplicate event, too big, etc).

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

4 participants