|
@@ -1,16 +1,16 @@
|
|
|
package main
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
- "fmt"
|
|
|
|
|
- "gopkg.in/urfave/cli.v1"
|
|
|
|
|
- "os"
|
|
|
|
|
|
|
+ "fmt"
|
|
|
|
|
+ "gopkg.in/urfave/cli.v1"
|
|
|
|
|
+ "os"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var onePeerCommand = cli.Command{
|
|
var onePeerCommand = cli.Command{
|
|
|
- Name: "one",
|
|
|
|
|
- Usage: "only one peer test.",
|
|
|
|
|
- Action: one,
|
|
|
|
|
- Flags: []cli.Flag {
|
|
|
|
|
|
|
+ Name: "one",
|
|
|
|
|
+ Usage: "only one peer test.",
|
|
|
|
|
+ Action: one,
|
|
|
|
|
+ Flags: []cli.Flag{
|
|
|
bootnodesFlag,
|
|
bootnodesFlag,
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
@@ -23,16 +23,20 @@ func one(ctx *cli.Context) {
|
|
|
// os.Exit(1)
|
|
// os.Exit(1)
|
|
|
//}
|
|
//}
|
|
|
|
|
|
|
|
- fmt.Fprintf(os.Stdout, "Hello one peer kit, node is %v.\n", ctx.String(bootnodesFlag.Name))
|
|
|
|
|
|
|
+ fmt.Fprintf(os.Stdout, "Hello one peer kit.\n")
|
|
|
|
|
|
|
|
disc := startV4(ctx)
|
|
disc := startV4(ctx)
|
|
|
defer disc.Close()
|
|
defer disc.Close()
|
|
|
|
|
|
|
|
- //for {
|
|
|
|
|
- // fmt.Println(nodes.Node().String())
|
|
|
|
|
- //
|
|
|
|
|
- // if !nodes.Next() {
|
|
|
|
|
- // nodes.Close()
|
|
|
|
|
- // }
|
|
|
|
|
- //}
|
|
|
|
|
|
|
+ nodes := disc.RandomNodes()
|
|
|
|
|
+ nodeCount := 0
|
|
|
|
|
+ for {
|
|
|
|
|
+ if !nodes.Next() {
|
|
|
|
|
+ nodes.Close()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ node := nodes.Node()
|
|
|
|
|
+ fmt.Printf("%v, %v\n", node.IP(), nodeCount)
|
|
|
|
|
+ nodeCount++
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|