@cryptotaxi247 / kubo / commits / 19caad230

add trickle-dag support to the urlstore

fixes #5241 License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Jul 16, 2018 at 12:33 UTC 19caad2301e5cccb53627b1ba550c1530dd085b1
1 file changed +12 -2
core/commands/urlstore.go
+12 -2
@@ -8,6 +8,7 @@ import (
8 filestore "github.com/ipfs/go-ipfs/filestore"
9 balanced "github.com/ipfs/go-ipfs/importer/balanced"
10 ihelper "github.com/ipfs/go-ipfs/importer/helpers"
11 + trickle "github.com/ipfs/go-ipfs/importer/trickle"
12
13 cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
14 mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
@@ -42,6 +43,9 @@ found. It may disappear or the semantics can change at any
43 time.
44 `,
45 },
46 + Options: []cmdkit.Option{
47 + cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
48 + },
49 Arguments: []cmdkit.Argument{
50 cmdkit.StringArg("url", true, false, "URL to add to IPFS"),
51 },
@@ -71,6 +75,8 @@ time.
75 return
76 }
77
78 + useTrickledag, _ := req.Options[trickleOptionName].(bool)
79 +
80 hreq, err := http.NewRequest("GET", url, nil)
81 if err != nil {
82 res.SetError(err, cmdkit.ErrNormal)
@@ -98,14 +104,18 @@ time.
104 URL: url,
105 }
106
101 - blc, err := balanced.Layout(dbp.New(chk))
107 + layout := balanced.Layout
108 + if useTrickledag {
109 + layout = trickle.Layout
110 + }
111 + root, err := layout(dbp.New(chk))
112 if err != nil {
113 res.SetError(err, cmdkit.ErrNormal)
114 return
115 }
116
117 cmds.EmitOnce(res, BlockStat{
108 - Key: blc.Cid().String(),
118 + Key: root.Cid().String(),
119 Size: int(hres.ContentLength),
120 })
121 },