-
Notifications
You must be signed in to change notification settings - Fork 58
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: update go-ipld-format and boxo to remove globals #296
Merged
hsanjuan
merged 2 commits into
hsanjuan:master
from
aschmahmann:feat/remove-ipld-format-globals
Aug 10, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,8 @@ import ( | |
"github.com/ipfs/boxo/ipld/unixfs/importer/trickle" | ||
ufsio "github.com/ipfs/boxo/ipld/unixfs/io" | ||
provider "github.com/ipfs/boxo/provider" | ||
"github.com/ipfs/boxo/provider/queue" | ||
"github.com/ipfs/boxo/provider/simple" | ||
"github.com/ipfs/go-cid" | ||
"github.com/ipfs/go-datastore" | ||
cbor "github.com/ipfs/go-ipld-cbor" | ||
ipld "github.com/ipfs/go-ipld-format" | ||
logging "github.com/ipfs/go-log/v2" | ||
"github.com/libp2p/go-libp2p/core/host" | ||
|
@@ -37,12 +34,6 @@ import ( | |
"github.com/multiformats/go-multihash" | ||
) | ||
|
||
func init() { | ||
ipld.Register(cid.DagProtobuf, merkledag.DecodeProtobufBlock) | ||
ipld.Register(cid.Raw, merkledag.DecodeRawBlock) | ||
ipld.Register(cid.DagCBOR, cbor.DecodeBlock) // need to decode CBOR | ||
} | ||
|
||
var logger = logging.Logger("ipfslite") | ||
|
||
var ( | ||
|
@@ -176,30 +167,20 @@ func (p *Peer) setupDAGService() error { | |
|
||
func (p *Peer) setupReprovider() error { | ||
if p.cfg.Offline || p.cfg.ReprovideInterval < 0 { | ||
p.reprovider = provider.NewOfflineProvider() | ||
p.reprovider = provider.NewNoopProvider() | ||
return nil | ||
} | ||
|
||
queue, err := queue.NewQueue(p.ctx, "repro", p.store) | ||
prov, err := provider.New(p.store, | ||
provider.DatastorePrefix(datastore.NewKey("repro")), | ||
provider.Online(p.dht), | ||
provider.ReproviderInterval(p.cfg.ReprovideInterval), | ||
provider.KeyProvider(provider.NewBlockstoreProvider(p.bstore))) | ||
if err != nil { | ||
return err | ||
} | ||
p.reprovider = prov | ||
Comment on lines
+170
to
+182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There were changes to the provider subsystem so this is what it should look like now |
||
|
||
prov := simple.NewProvider( | ||
p.ctx, | ||
queue, | ||
p.dht, | ||
) | ||
|
||
reprov := simple.NewReprovider( | ||
p.ctx, | ||
p.cfg.ReprovideInterval, | ||
p.dht, | ||
simple.NewBlockstoreProvider(p.bstore), | ||
) | ||
|
||
p.reprovider = provider.NewSystem(prov, reprov) | ||
p.reprovider.Run() | ||
return nil | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 appear unneeded, is there something I'm missing here?
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.
I'm relatively confident that without these you would do a ipfslite.DagService.Get() and the thing would error because it didn't know how to parse stuff (particularly with CBOR).
Perhaps this is no longer the case, perhaps these are preregistered somewhere else, I don't know. It was a way to not make the users go through the hassle of figuring out that they have to register the codecs they want to use.
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.
So the merkledag library will still have a global registry for now ipfs/boxo#322 that will use the global go-ipld-prime registry + some overrides for dag-pb and raw which means the dagservice will be fine.
I don't think a breaking change to go-merkledag is in the cards for this round of PRs, but if you'd like the registry used by merkledag to be configurable I'm cool exposing it as a public global with sufficient warnings around it.