-
Notifications
You must be signed in to change notification settings - Fork 7
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
Make live queries aware of reindexed (decrypted) values #236
Conversation
Benchmark results
|
Thanks for tackling this! What do you think about a new API for this? I'm wondering if adding these decrypted msgs into the live() will break some assumptions about our APIs. Two assumptions: (1) every message appears in the stream only once, (2) live stream delivers only msgs recently added to the log. |
That is a good point. I considered that, but as you can see this is only in live. So for this to happen you would have to receive a message and the key at almost the same time. I fear that a new api might be a gotcha. |
Wouldn't it be possible to read the same msg from the live stream, even if receival time is very different to decryption time? Like if I subscribe to this live stream at 13:00, then receive a box2 encrypted msg at 13:02, and then later I'm added to a group at 14:00 and thus I get the decrypted msg at 14:00. What I'm worried is that we're do a breaking change on live() and then creating new issues somewhere downstream. It's easier to make a non-breaking change with a new API. |
It's an interesting question about semantics 🙂 like what did the original live promise and how does it relate to box 2 which is a bit different in that you can not suddenly read older messages. Thinking about this some more, maybe a good compromise would be to have two streams as you say and then people can combine them if needed. if it turns out that people do this pattern all the time, we can add a helper. In any case it will be really important to add this in the documentation that live does not return newly decrypted messages but that comes quite naturally when added the new api to the docs. |
As for your query. It's true that if you did a query on the author only, then you would get it twice. Good point |
I like that compromise.
From our readme, it says (bold is my emphasis):
|
Yeah, I'm working on that solution. It's almost ready, just have to get all the tests working. It's a pitty that live has this old: true flag, in that when we add another operator (like decrypted()) it gets a bit muddy what these mean when you combine them. But the diff is pretty short. Will share later when I get everything running properly. |
Also, if we split the stream then shouldn't this be implemented in ssb-db2? We can pick only the records that have been box2 decrypted and pass them into some pull-stream. I actually don't understand how this PR #236 works, because it's adding the lowest offset of the range being reindexed, but we should be streaming all the offsets that have been decrypted within that range. |
Sorry for yet another comment, but
I see now how it works because https://github.com/ssbc/ssb-db2/blob/b095c33cde3be59ce6e6e69be47ce80fdaf8116e/core.js#L1015 is called for all the just-decrypted records, BUT shouldn't we change this implementation such that we only call jitdb.reindex for the minimum offset, such that this offset covers the whole range of decrypted records? See e.g. that Airtable task about optimizing reindexEncrypted, and ssbc/ssb-db2#407 |
Thanks for the input, working on a better solution now. |
With this ssbc/ssb-db2#410 is now working. Clearly this needs a test here as well. But first I was wondering if this would be a good approach or not?