-
Notifications
You must be signed in to change notification settings - Fork 8
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 sure that deleteFeed is idempotent and performant #344
Conversation
const pValueAuthor = bipf.seekKey2(buf, pValue, BIPF_AUTHOR, 0) | ||
const pValueSequence = bipf.seekKey2(buf, pValue, BIPF_SEQUENCE, 0) | ||
const author = bipf.decode(buf, pValueAuthor) | ||
const sequence = bipf.decode(buf, pValueSequence) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are unrelated to the PR, but when I ran prettier
, the decode
ended up taking many lines, so I refactored to create the pValueAuthor
and keep each of these a one-liner.
Mysterious, why isn't the CI completing within 10minutes... Whaaat, the |
Maybe CI acting up. Node 16 ran fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
I investigated this locally by running |
Tests pass locally with node.js 12 and 14 and 16 so I'll merge. |
Context: I have an idea for deleting blocked feeds in an automatic way: use
ssb-friends
to scan all the blocked feeds and calldeleteFeed
on them. In case those feeds were already deleted, we need to make sure thatdeleteFeed
is going to be performant and not cause any bugs.Solution: when clearing the
base
index, this PR now checks first if an entry exists for thatfeedId
. If it exists, then we can avoid callingflush
andlevel.del
in vain.An important thing to keep in mind is that
deleteFeed
is not atomic. The app may crash in the middle of adeleteFeed
, meaning that some messages owned by that feed are deleted, but not all of them. So in a sense it's desired to calldeleteFeed
every time the app is opened, to make sure all messages are deleted.Check more comments I put in the implementation of
deleteFeed
just to explain my points better: