diff --git a/cmd/swarm/explore.go b/cmd/swarm/explore.go
new file mode 100644
index 0000000000..9fdb2c674e
--- /dev/null
+++ b/cmd/swarm/explore.go
@@ -0,0 +1,58 @@
+// Copyright 2016 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with go-ethereum. If not, see .
+
+// Command bzzhash computes a swarm tree hash.
+package main
+
+import (
+ "context"
+ "fmt"
+ "os"
+
+ "github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/swarm/storage"
+ "gopkg.in/urfave/cli.v1"
+)
+
+var chunkExploreCommand = cli.Command{
+ Action: explore,
+ CustomHelpTemplate: helpTemplate,
+ Name: "explore",
+ Usage: "print all hashes of a file to STDOUT",
+ ArgsUsage: "",
+ Description: "Prints all hashes of a file to STDOUT",
+}
+
+func explore(ctx *cli.Context) {
+ args := ctx.Args()
+ if len(args) < 1 {
+ utils.Fatalf("Usage: swarm explore ")
+ }
+ f, err := os.Open(args[0])
+ if err != nil {
+ utils.Fatalf("Error opening file " + args[1])
+ }
+ defer f.Close()
+
+ fileStore := storage.NewFileStore(&storage.FakeChunkStore{}, storage.NewFileStoreParams())
+ _, err = fileStore.StoreToExplore(context.TODO(), f)
+ if err != nil {
+ utils.Fatalf("%v\n", err)
+ } else {
+ //fmt.Printf("%v\n", addr)
+ fmt.Println("Done.")
+ }
+}
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go
index 53888b615f..7f45db74c8 100644
--- a/cmd/swarm/main.go
+++ b/cmd/swarm/main.go
@@ -142,6 +142,8 @@ func init() {
dbCommand,
// See config.go
DumpConfigCommand,
+ // chunkExploreCommand
+ chunkExploreCommand,
}
// append a hidden help subcommand to all commands that have subcommands
diff --git a/cmd/swarm/swarm-smoke/chunkExplorer.go b/cmd/swarm/swarm-smoke/chunkExplorer.go
new file mode 100644
index 0000000000..437d5894cc
--- /dev/null
+++ b/cmd/swarm/swarm-smoke/chunkExplorer.go
@@ -0,0 +1,56 @@
+// Copyright 2018 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with go-ethereum. If not, see .
+
+package main
+
+import (
+ "fmt"
+
+ "github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/rpc"
+ cli "gopkg.in/urfave/cli.v1"
+)
+
+var (
+ addr string
+)
+
+func chunkExplorer(c *cli.Context) error {
+ fmt.Println("generate endpoints...")
+ //generateEndpoints(scheme, cluster, appName, from, to)
+ fmt.Println("done.")
+
+ var has bool
+ //for _, e := range endpoints {
+ e := "ws://localhost"
+ fmt.Println("dialing...." + e + ":8546")
+ client, _ := rpc.Dial(e + ":8546")
+ fmt.Println("Trying...." + e)
+ if err := client.Call(&has, "debugapi_hasChunk", addr); err != nil {
+ fmt.Println("err")
+ log.Error("Error requesting hasChunk from endpoint", "endpoint", e, "chunkAddress", addr, "err", err)
+ } else {
+ if has {
+ fmt.Println("has")
+ log.Info("Endpoint "+e+" reports to HAVE chunk", "chunk", addr)
+ } else {
+ fmt.Println("not")
+ log.Debug("Endpoint "+e+" reports to NOT have chunk", "chunk", addr)
+ }
+ }
+ //}
+ return nil
+}
diff --git a/cmd/swarm/swarm-smoke/main.go b/cmd/swarm/swarm-smoke/main.go
index 5596714605..c5ce718f5e 100644
--- a/cmd/swarm/swarm-smoke/main.go
+++ b/cmd/swarm/swarm-smoke/main.go
@@ -88,6 +88,12 @@ func main() {
Usage: "http or https",
Destination: &scheme,
},
+ cli.StringFlag{
+ Name: "addr",
+ Value: "",
+ Usage: "chunk address",
+ Destination: &addr,
+ },
cli.BoolFlag{
Name: "include-localhost",
Usage: "whether to include localhost:8500 as an endpoint",
@@ -160,6 +166,12 @@ func main() {
Usage: "measure network aggregate capacity",
Action: wrapCliCommand("sliding-window", false, slidingWindow),
},
+ {
+ Name: "chunk_explorer",
+ Aliases: []string{"x"},
+ Usage: "query nodes if they are storing a specific chunk (by address)",
+ Action: wrapCliCommand("chunkExplorer", false, chunkExplorer),
+ },
}
sort.Sort(cli.FlagsByName(app.Flags))