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

Update for LinkSystem #161

Merged
merged 6 commits into from
Mar 26, 2021
Merged

Update for LinkSystem #161

merged 6 commits into from
Mar 26, 2021

Conversation

hannahhoward
Copy link
Collaborator

Goals

Update for IPLD's LinkSystem

Implementation

There were a couple ways to go here, I went for the one that's more breaking, but more in link with the linksystem design.

Basically, anywhere we take in a loader and a storer, now we take a linksystem. I don't know if we will encounter loads of places where we might replace the encoders, decoders, and hashers, but it seems worth doing.

The alternative would just be to replace the old ipld.Loader & ipld.Storer with ipld.BlockReadOpener and ipld.BlockWriterOpener

I kept it this way for a few low level calls.

mvdan and others added 2 commits March 8, 2021 17:48
replace most instances of loader and storer with ipld.LinkSystem
@hannahhoward
Copy link
Collaborator Author

@warpfork would love to get your opinion on this.

@hannahhoward hannahhoward changed the title Update for LinkSystem DO NOT MERGE: Update for LinkSystem Mar 12, 2021
Comment on lines +86 to +94
if tb.LinkSystem.DecoderChooser == nil {
t.linkSystem.DecoderChooser = defaultLinkSystem.DecoderChooser
}
if tb.LinkSystem.EncoderChooser == nil {
t.linkSystem.EncoderChooser = defaultLinkSystem.EncoderChooser
}
if tb.LinkSystem.HasherChooser == nil {
t.linkSystem.HasherChooser = defaultLinkSystem.HasherChooser
}
Copy link
Member

Choose a reason for hiding this comment

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

I think these might be kind of excessive? LinkSystem should give reasonable error messages if these are unset, so I think it's reasonable to presume their existence. Not at all a strongly held opinion though; if this made an API easier to use, carry on.

@warpfork
Copy link
Member

Agree, the big design question is if things should mostly pass around LinkSystem or mostly pass around BlockWriteOpener+BlockReadOpener and construct a LinkSystem on demand.

These diffs went for the former. The result looks totally reasonable.

👍

// from an IPFS blockstore
func LoaderForBlockstore(bs bstore.Blockstore) ipld.Loader {
return func(lnk ipld.Link, lnkCtx ipld.LinkContext) (io.Reader, error) {
// LinkSystemForBlockstore constructs an IPLD LinkSystem for a blockstore
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this repo (graphsync) the best place for this to live? can we put it in the blockstore and/or in cidlink?
(@warpfork do you think this would be reasonable to live in cidlink?)

Copy link
Member

Choose a reason for hiding this comment

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

That's a good question. I don't have a strong opinion.

If we end up writing this a lot of times in a lot of places, then maybe it makes sense to put it somewhere in the go-ipld-prime repo. Probably not the cidlink package directly -- because I'd like use of that package to drag in go-cid and nothing else -- but some other glue package of the same general pattern as cidlink could end up being reasonable.

Maybe putting it in the blockstore repo could make sense, too. I think that would tend to work and should not result in cycles.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it should migrate IMHO, eventually.

@hannahhoward hannahhoward changed the title DO NOT MERGE: Update for LinkSystem Update for LinkSystem Mar 25, 2021
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.

4 participants