Skip to content

Commit

Permalink
feat: switch dag import command to use default go-ipld-legacy block d…
Browse files Browse the repository at this point in the history
…ecoder
  • Loading branch information
aschmahmann committed May 31, 2023
1 parent cfa056d commit dbfb4e9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/commands/dag/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ func dagImport(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment
return err
}

blockDecoder := ipldlegacy.NewDecoder()

// on import ensure we do not reach out to the network for any reason
// if a pin based on what is imported + what is in the blockstore
// isn't possible: tough luck
Expand Down Expand Up @@ -94,7 +96,7 @@ func dagImport(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment
}

// the double-decode is suboptimal, but we need it for batching
nd, err := ipldlegacy.DecodeNode(req.Context, block)
nd, err := blockDecoder.DecodeNode(req.Context, block)
if err != nil {
return err
}
Expand Down Expand Up @@ -131,7 +133,7 @@ func dagImport(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment
// and ensure the gray bucket is empty at the end (or use the network to download missing blocks).
if block, err := node.Blockstore.Get(req.Context, c); err != nil {
ret.PinErrorMsg = err.Error()
} else if nd, err := ipldlegacy.DecodeNode(req.Context, block); err != nil {
} else if nd, err := blockDecoder.DecodeNode(req.Context, block); err != nil {
ret.PinErrorMsg = err.Error()
} else if err := node.Pinning.Pin(req.Context, nd, true); err != nil {
ret.PinErrorMsg = err.Error()
Expand Down

0 comments on commit dbfb4e9

Please sign in to comment.