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

Implement feed.audit() #47

Open
yoshuawuyts opened this issue Nov 6, 2018 · 5 comments
Open

Implement feed.audit() #47

yoshuawuyts opened this issue Nov 6, 2018 · 5 comments
Labels
enhancement New feature or request

Comments

@yoshuawuyts
Copy link
Contributor

Feature Request

Summary

Implement feed.audit() to verify all data you think you have is actually there.

Motivation

This gives us parity with holepunchto/hypercore#180.

@yoshuawuyts yoshuawuyts added the enhancement New feature or request label Nov 6, 2018
@tdeebswihart
Copy link
Contributor

Good morning. I've implemented feed.audit() over here.

However thanks to Rust's borrow checker I'm having trouble writing a test for the "bad data" scenario: it wisely prevents me from altering storage while the Feed has ownership of it.

Any idea of how to insert bad data here?

@yoshuawuyts
Copy link
Contributor Author

@chronoslynx oh that's awesome! -- a PR would be super welcome, even if there isn't any test data included yet! Apologies for not replying sooner; I was on vacation for the past few weeks.

I'm not quite sure how to edit the bad data yet, haha. Perhaps if we re-initialize the feed from disk we can get it into a bad state? Perhaps we can workshop this a bit in the PR?

Thanks so much for putting in the work; that's amazing! :D

@tdeebswihart
Copy link
Contributor

Hey, no need to apologize. Vacation is important!

Inserting bad data will be... weird. Does it write the data immediately to disk (if you're using disk-backed storage)? If so (and we can get the filename), we can open a second handle to it and stomp the data.
I'll need to read into your storage implementation to see

@yoshuawuyts
Copy link
Contributor Author

Inserting bad data will be... weird. Does it write the data immediately to disk (if you're using disk-backed storage)? If so (and we can get the filename), we can open a second handle to it and stomp the data.

Yeah, that's what I was thinking! -- It's very possible that might surface some other fun issues, but that'll be good to verify!

We implement fsync() on Drop in random-access-storage, so that should probably work!

@tdeebswihart
Copy link
Contributor

fsync is also called after every write, and the disk is consulted on every read which leads to this being simpler than I expected.

It's brittle, however. If the disk implementation every changes the name of the data file, then this test will break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants