jb55 on Nostr: Here’s a visual way to get a sense of filter optimization in the local relay model. ...
Here’s a visual way to get a sense of filter optimization in the local relay model. See quoted post for motivation.
Once you define the is_subset function you just call this for each filter on every other filter. This creates an array of true/false for each filter. This is equivalent to there being an arrow above each filter in the diagram. then you just remove each filter if the value is true for that index. Simple!
Adding this to the nostrdb api, might come in handy for anyone implementing the local relay model.
Once you define the is_subset function you just call this for each filter on every other filter. This creates an array of true/false for each filter. This is equivalent to there being an arrow above each filter in the diagram. then you just remove each filter if the value is true for that index. Simple!
Adding this to the nostrdb api, might come in handy for anyone implementing the local relay model.
quoting note183q…f9p5On the plane I came up with an algorithm that does the following:
given a set of filters, find all filters that are redundant. It pretty simple, you just determine if a filter is a subset of any other filter in the set, and then you prune those.
Example: everything is a subset of {}, the filter that matches everything, so this algorithm could take a list of 100 filters, and if {} was present it would only return that 1 filter.
This is useful for notedeck, as you would only need to open the minimal number of subscriptions remotely, while still having granular local filters active on nostrdb.
Will write up this algo soon, i have some of the code done already.
gm nostr