@@ -25,6 +25,7 @@ import (
2525 "strings"
2626
2727 "github.com/ethereum/go-ethereum/cmd/utils"
28+ "github.com/ethereum/go-ethereum/swarm/api"
2829 swarm "github.com/ethereum/go-ethereum/swarm/api/client"
2930 "gopkg.in/urfave/cli.v1"
3031)
@@ -42,7 +43,7 @@ func add(ctx *cli.Context) {
4243
4344 ctype string
4445 wantManifest = ctx .GlobalBoolT (SwarmWantManifestFlag .Name )
45- mroot swarm .Manifest
46+ mroot api .Manifest
4647 )
4748
4849 if len (args ) > 3 {
@@ -76,7 +77,7 @@ func update(ctx *cli.Context) {
7677
7778 ctype string
7879 wantManifest = ctx .GlobalBoolT (SwarmWantManifestFlag .Name )
79- mroot swarm .Manifest
80+ mroot api .Manifest
8081 )
8182 if len (args ) > 3 {
8283 ctype = args [3 ]
@@ -106,7 +107,7 @@ func remove(ctx *cli.Context) {
106107 path = args [1 ]
107108
108109 wantManifest = ctx .GlobalBoolT (SwarmWantManifestFlag .Name )
109- mroot swarm .Manifest
110+ mroot api .Manifest
110111 )
111112
112113 newManifest := removeEntryFromManifest (ctx , mhash , path )
@@ -125,11 +126,7 @@ func addEntryToManifest(ctx *cli.Context, mhash, path, hash, ctype string) strin
125126 var (
126127 bzzapi = strings .TrimRight (ctx .GlobalString (SwarmApiFlag .Name ), "/" )
127128 client = swarm .NewClient (bzzapi )
128- longestPathEntry = swarm.ManifestEntry {
129- Path : "" ,
130- Hash : "" ,
131- ContentType : "" ,
132- }
129+ longestPathEntry = api.ManifestEntry {}
133130 )
134131
135132 mroot , err := client .DownloadManifest (mhash )
@@ -163,7 +160,7 @@ func addEntryToManifest(ctx *cli.Context, mhash, path, hash, ctype string) strin
163160 newHash := addEntryToManifest (ctx , longestPathEntry .Hash , newPath , hash , ctype )
164161
165162 // Replace the hash for parent Manifests
166- newMRoot := swarm .Manifest {}
163+ newMRoot := & api .Manifest {}
167164 for _ , entry := range mroot .Entries {
168165 if longestPathEntry .Path == entry .Path {
169166 entry .Hash = newHash
@@ -173,9 +170,9 @@ func addEntryToManifest(ctx *cli.Context, mhash, path, hash, ctype string) strin
173170 mroot = newMRoot
174171 } else {
175172 // Add the entry in the leaf Manifest
176- newEntry := swarm.ManifestEntry {
177- Path : path ,
173+ newEntry := api.ManifestEntry {
178174 Hash : hash ,
175+ Path : path ,
179176 ContentType : ctype ,
180177 }
181178 mroot .Entries = append (mroot .Entries , newEntry )
@@ -192,18 +189,10 @@ func addEntryToManifest(ctx *cli.Context, mhash, path, hash, ctype string) strin
192189func updateEntryInManifest (ctx * cli.Context , mhash , path , hash , ctype string ) string {
193190
194191 var (
195- bzzapi = strings .TrimRight (ctx .GlobalString (SwarmApiFlag .Name ), "/" )
196- client = swarm .NewClient (bzzapi )
197- newEntry = swarm.ManifestEntry {
198- Path : "" ,
199- Hash : "" ,
200- ContentType : "" ,
201- }
202- longestPathEntry = swarm.ManifestEntry {
203- Path : "" ,
204- Hash : "" ,
205- ContentType : "" ,
206- }
192+ bzzapi = strings .TrimRight (ctx .GlobalString (SwarmApiFlag .Name ), "/" )
193+ client = swarm .NewClient (bzzapi )
194+ newEntry = api.ManifestEntry {}
195+ longestPathEntry = api.ManifestEntry {}
207196 )
208197
209198 mroot , err := client .DownloadManifest (mhash )
@@ -237,7 +226,7 @@ func updateEntryInManifest(ctx *cli.Context, mhash, path, hash, ctype string) st
237226 newHash := updateEntryInManifest (ctx , longestPathEntry .Hash , newPath , hash , ctype )
238227
239228 // Replace the hash for parent Manifests
240- newMRoot := swarm .Manifest {}
229+ newMRoot := & api .Manifest {}
241230 for _ , entry := range mroot .Entries {
242231 if longestPathEntry .Path == entry .Path {
243232 entry .Hash = newHash
@@ -250,12 +239,12 @@ func updateEntryInManifest(ctx *cli.Context, mhash, path, hash, ctype string) st
250239
251240 if newEntry .Path != "" {
252241 // Replace the hash for leaf Manifest
253- newMRoot := swarm .Manifest {}
242+ newMRoot := & api .Manifest {}
254243 for _ , entry := range mroot .Entries {
255244 if newEntry .Path == entry .Path {
256- myEntry := swarm.ManifestEntry {
257- Path : entry .Path ,
245+ myEntry := api.ManifestEntry {
258246 Hash : hash ,
247+ Path : entry .Path ,
259248 ContentType : ctype ,
260249 }
261250 newMRoot .Entries = append (newMRoot .Entries , myEntry )
@@ -276,18 +265,10 @@ func updateEntryInManifest(ctx *cli.Context, mhash, path, hash, ctype string) st
276265func removeEntryFromManifest (ctx * cli.Context , mhash , path string ) string {
277266
278267 var (
279- bzzapi = strings .TrimRight (ctx .GlobalString (SwarmApiFlag .Name ), "/" )
280- client = swarm .NewClient (bzzapi )
281- entryToRemove = swarm.ManifestEntry {
282- Path : "" ,
283- Hash : "" ,
284- ContentType : "" ,
285- }
286- longestPathEntry = swarm.ManifestEntry {
287- Path : "" ,
288- Hash : "" ,
289- ContentType : "" ,
290- }
268+ bzzapi = strings .TrimRight (ctx .GlobalString (SwarmApiFlag .Name ), "/" )
269+ client = swarm .NewClient (bzzapi )
270+ entryToRemove = api.ManifestEntry {}
271+ longestPathEntry = api.ManifestEntry {}
291272 )
292273
293274 mroot , err := client .DownloadManifest (mhash )
@@ -319,7 +300,7 @@ func removeEntryFromManifest(ctx *cli.Context, mhash, path string) string {
319300 newHash := removeEntryFromManifest (ctx , longestPathEntry .Hash , newPath )
320301
321302 // Replace the hash for parent Manifests
322- newMRoot := swarm .Manifest {}
303+ newMRoot := & api .Manifest {}
323304 for _ , entry := range mroot .Entries {
324305 if longestPathEntry .Path == entry .Path {
325306 entry .Hash = newHash
@@ -331,7 +312,7 @@ func removeEntryFromManifest(ctx *cli.Context, mhash, path string) string {
331312
332313 if entryToRemove .Path != "" {
333314 // remove the entry in this Manifest
334- newMRoot := swarm .Manifest {}
315+ newMRoot := & api .Manifest {}
335316 for _ , entry := range mroot .Entries {
336317 if entryToRemove .Path != entry .Path {
337318 newMRoot .Entries = append (newMRoot .Entries , entry )
0 commit comments