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

feat: add unified recon block store implementation #245

Merged
merged 2 commits into from
Jan 29, 2024
Merged

Conversation

nathanielc
Copy link
Collaborator

Add a unified store that can both store Recon values and expose them as IPFS blocks.

This change also makes all the IPFS read only. Its not longer possible to store arbitrary blocks but instead all data must ingress via Recon.

Note the Interests store remains unmodified.

I have not performance tested this change yet.

Add a unified store that can both store Recon values and expose them as
IPFS blocks.

This change also makes all the IPFS read only. Its not longer possible
to store arbitrary blocks but instead all data must ingress via Recon.

Note the Interests store remains unmodified.
Copy link

linear bot commented Jan 26, 2024

.await
.map_err(Error::Internal)?
.ok_or(Error::NotFound)?)
if self.store.has(&cid).await.map_err(Error::Internal)? {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter if we call has -> get_size instead of just calling get_size and handle the error if the CID is absent? Same question for block_get.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can't tell the difference between an error reading from the database and an error that the block does not exist. We could update the iroh_bitswap Store trait to either return a Result<Option<>> but I didn't make that change with this PR.

});
let mut root_bytes = Vec::new();
root.encode(DagCborCodec, &mut root_bytes).unwrap();
let root_cid = Cid::new_v1(0x71, MultihashDigest::digest(&Code::Sha2_256, &root_bytes));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use IpldCodec::DagCbor.into() in place of 0x71.

store/src/tests.rs Show resolved Hide resolved
@smrz2001
Copy link
Collaborator

Really like the new code organization! 🥳

@nathanielc
Copy link
Collaborator Author

I have run the perf tests locally and compared with main. There was no significant difference in performance between main and this change.

This PR is now ready for review.

@nathanielc nathanielc marked this pull request as ready for review January 29, 2024 18:46
@nathanielc nathanielc requested review from smrz2001 and dav1do January 29, 2024 20:51
Copy link
Collaborator

@smrz2001 smrz2001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 🚀

(I reviewed most of it a couple of days ago)

@nathanielc nathanielc added this pull request to the merge queue Jan 29, 2024
Merged via the queue into main with commit a282a23 Jan 29, 2024
4 checks passed
@nathanielc nathanielc deleted the feature/ws1-1446 branch January 29, 2024 23:00
@github-actions github-actions bot mentioned this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants