提交 19caad23 作者: Steven Allen

add trickle-dag support to the urlstore

fixes #5241

License: MIT
Signed-off-by: 's avatarSteven Allen <steven@stebalien.com>
上级 89e1d9fd
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
filestore "github.com/ipfs/go-ipfs/filestore" filestore "github.com/ipfs/go-ipfs/filestore"
balanced "github.com/ipfs/go-ipfs/importer/balanced" balanced "github.com/ipfs/go-ipfs/importer/balanced"
ihelper "github.com/ipfs/go-ipfs/importer/helpers" ihelper "github.com/ipfs/go-ipfs/importer/helpers"
trickle "github.com/ipfs/go-ipfs/importer/trickle"
cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds" cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash" mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
...@@ -42,6 +43,9 @@ found. It may disappear or the semantics can change at any ...@@ -42,6 +43,9 @@ found. It may disappear or the semantics can change at any
time. time.
`, `,
}, },
Options: []cmdkit.Option{
cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
},
Arguments: []cmdkit.Argument{ Arguments: []cmdkit.Argument{
cmdkit.StringArg("url", true, false, "URL to add to IPFS"), cmdkit.StringArg("url", true, false, "URL to add to IPFS"),
}, },
...@@ -71,6 +75,8 @@ time. ...@@ -71,6 +75,8 @@ time.
return return
} }
useTrickledag, _ := req.Options[trickleOptionName].(bool)
hreq, err := http.NewRequest("GET", url, nil) hreq, err := http.NewRequest("GET", url, nil)
if err != nil { if err != nil {
res.SetError(err, cmdkit.ErrNormal) res.SetError(err, cmdkit.ErrNormal)
...@@ -98,14 +104,18 @@ time. ...@@ -98,14 +104,18 @@ time.
URL: url, URL: url,
} }
blc, err := balanced.Layout(dbp.New(chk)) layout := balanced.Layout
if useTrickledag {
layout = trickle.Layout
}
root, err := layout(dbp.New(chk))
if err != nil { if err != nil {
res.SetError(err, cmdkit.ErrNormal) res.SetError(err, cmdkit.ErrNormal)
return return
} }
cmds.EmitOnce(res, BlockStat{ cmds.EmitOnce(res, BlockStat{
Key: blc.Cid().String(), Key: root.Cid().String(),
Size: int(hres.ContentLength), Size: int(hres.ContentLength),
}) })
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论