Implement NIP-91: AND operator in filters#177
Open
btcjt wants to merge 2 commits intohoytech:masterfrom
Open
Conversation
Add support for &-prefixed tag filters that require ALL listed values to be present on an event (AND logic), complementing the existing #-prefixed OR filters. - Parse &X filter keys and store in andTags map - doesMatch() verifies all AND tag values are present - DBScan selects optimal index (AND tags need only 1 cursor) - ActiveMonitors registers AND tag values for real-time matching - Advertise NIP-91 support in NIP-11 relay info
Update dumbFilter.pl reference implementation to handle &-prefixed AND tag filters. Add random &t filter generation to filterFuzzTest.pl so the differential fuzzer exercises AND filter matching. Add genTestData.pl to generate synthetic events with t-tags for testing, and runTests.sh for running the test suite in Docker. Verified all tests pass (Docker Alpine build): - scan: 30/30 passed - scan-limit: 30/30 passed - monitor: 15/15 passed
b4880fc to
aaa2d6c
Compare
|
Nice! #162 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
&-prefixed tag filters (NIP-91) that require ALL listed values to be present on an event (AND logic), complementing the existing#-prefixed OR filters{"&t": ["meme", "cat"], "#t": ["black", "white"]}returns events with botht=memeANDt=cat, that also havet=blackORt=whiteChanges
&Xkeys intoandTagsmap;doesMatch()verifies all AND values present; updatedisFullDbQuery,indexOnlyScans, and tag count limitsallTagsinverted index for real-time subscription matchingTest plan
&tfilter and confirm only events with ALL specified tag values are returned&tand#tfilters and confirm AND takes precedence over OR