cmd/swarm: explore -> hashes command; remove chunk-explorer in swarm-smoke

This commit is contained in:
Fabio Barone 2019-02-04 12:57:34 -05:00
parent 3a783d508c
commit efa7a4083f
3 changed files with 4 additions and 67 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2016 The go-ethereum Authors // Copyright 2019 The go-ethereum Authors
// This file is part of go-ethereum. // This file is part of go-ethereum.
// //
// go-ethereum is free software: you can redistribute it and/or modify // go-ethereum is free software: you can redistribute it and/or modify
@ -28,15 +28,15 @@ import (
) )
var chunkExploreCommand = cli.Command{ var chunkExploreCommand = cli.Command{
Action: explore, Action: hashes,
CustomHelpTemplate: helpTemplate, CustomHelpTemplate: helpTemplate,
Name: "explore", Name: "hashes",
Usage: "print all hashes of a file to STDOUT", Usage: "print all hashes of a file to STDOUT",
ArgsUsage: "<file>", ArgsUsage: "<file>",
Description: "Prints all hashes of a file to STDOUT", Description: "Prints all hashes of a file to STDOUT",
} }
func explore(ctx *cli.Context) { func hashes(ctx *cli.Context) {
args := ctx.Args() args := ctx.Args()
if len(args) < 1 { if len(args) < 1 {
utils.Fatalf("Usage: swarm explore <file name>") utils.Fatalf("Usage: swarm explore <file name>")

View file

@ -1,51 +0,0 @@
// 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 <http://www.gnu.org/licenses/>.
package main
import (
"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 {
log.Debug("generate endpoints...")
generateEndpoints(scheme, cluster, appName, from, to)
log.Debug("done.")
var has bool
for _, e := range endpoints {
e = e + ":8546"
log.Debug("dialing...." + e)
client, _ := rpc.Dial(e)
log.Debug("Trying...." + e)
if err := client.Call(&has, "debugapi_hasChunk", addr); err != nil {
log.Error("Error requesting hasChunk from endpoint", "endpoint", e, "chunkAddress", addr, "err", err)
} else {
if has {
log.Info("Endpoint "+e+" reports to HAVE chunk", "chunk", addr)
} else {
log.Info("Endpoint "+e+" reports to NOT have chunk", "chunk", addr)
}
}
}
return nil
}

View file

@ -88,12 +88,6 @@ func main() {
Usage: "http or https", Usage: "http or https",
Destination: &scheme, Destination: &scheme,
}, },
cli.StringFlag{
Name: "addr",
Value: "<hash>",
Usage: "chunk address",
Destination: &addr,
},
cli.BoolFlag{ cli.BoolFlag{
Name: "include-localhost", Name: "include-localhost",
Usage: "whether to include localhost:8500 as an endpoint", Usage: "whether to include localhost:8500 as an endpoint",
@ -166,12 +160,6 @@ func main() {
Usage: "measure network aggregate capacity", Usage: "measure network aggregate capacity",
Action: wrapCliCommand("sliding-window", false, slidingWindow), 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)) sort.Sort(cli.FlagsByName(app.Flags))