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

Add pow field to filter JSON object #1514

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yukibtc
Copy link

@yukibtc yukibtc commented Sep 23, 2024

Add pow field to filter JSON object to allow query of events with a certain difficulty.

Read here

@smolgrrr
Copy link

smolgrrr commented Sep 25, 2024

i suppose in the future it would be nice if some relays chose to index the difficulty in the nonce tag e.g. ["nonce", "12345", "21"], and then you use a filter like this:
["REQ", <subscription_id>, {"#nonce": 21, ...}] (?) however instead of returning matches, it returns events where the difficulty specified in the nonce tag is greater than or equal to the REQ difficulty. PoW can then be verified on the client side as it should be.

obviously tag filtering only looks for matches at the moment, and it's also the actual nonce that follows the tag name not the difficulty, so it would be different logic to the standard way tag filtering works which isn't nice and is needless complexity.

@alexgleason
Copy link
Member

NIP-13 should have put the difficulty in the tag value and the nonce in the third position. Then it could at least be worked around by querying every integer below your target value, which honestly isn't even that bad. Introducing a new filter because of an issue with a tag seems wrong. I want to deprecate the "nonce" tag and replace it with a "pow" tag, but that would break too much stuff. This filter would make more sense as a NIP-50 search extension.

@pablof7z
Copy link
Member

cNACK -- I would rather see prefix REQs come back rather than have an explicit filter for pow.

@kehiy
Copy link
Contributor

kehiy commented Sep 30, 2024

cnack. im not sure where we need to query based on pow, but if it's really needed, adding a pow tag and querying based on it is a better way to add a new field to filter objects.

@yukibtc
Copy link
Author

yukibtc commented Sep 30, 2024

im not sure where we need to query based on pow

The use case is to reduce bandwidth and resources usage for apps that want to get only events with a certain POW (for spam reasons).

but if it's really needed, adding a pow tag and querying based on it is a better way to add a new field to filter objects.

Filter support only single letter tag:

nips/01.md

Line 127 in a736e62

"#<single-letter (a-zA-Z)>": <a list of tag values, for #e — a list of event ids, for #p — a list of pubkeys, etc.>,

Re-add prefix REQs would break things:

nips/01.md

Line 138 in a736e62

The `ids`, `authors`, `#e` and `#p` filter lists MUST contain exact 64-character lowercase hex values.

The same for adding support to non-single letter tags and changing NIP-13 tag (this will not allow to query old POW events).

I think that add the pow field to Filter is the solution that will not break things.

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

Successfully merging this pull request may close these issues.

5 participants