cmd/swarm/swarm-snapshot, swarm/network/simulations: removed redundant connection event check, fixed lint error

This commit is contained in:
Elad Nachmias 2019-01-16 13:38:02 +05:30
parent b866ba97b8
commit e37ade0671
2 changed files with 4 additions and 21 deletions

View file

@ -38,8 +38,6 @@ import (
cli "gopkg.in/urfave/cli.v1" cli "gopkg.in/urfave/cli.v1"
) )
const noConnectionTimeout = 1 * time.Second
// create is used as the entry function for "create" app command. // create is used as the entry function for "create" app command.
func create(ctx *cli.Context) error { func create(ctx *cli.Context) error {
log.PrintOrigins(true) log.PrintOrigins(true)
@ -83,20 +81,6 @@ func createSnapshot(filename string, nodes int, services []string) (err error) {
return fmt.Errorf("add nodes: %v", err) return fmt.Errorf("add nodes: %v", err)
} }
// wait for two some time to ensure no connections
// are established
events := make(chan *simulations.Event)
sub := sim.Net.Events().Subscribe(events)
select {
case ev := <-events:
//only catch node up events
if ev.Type == simulations.EventTypeConn {
return errors.New("unexpected connection events")
}
case <-time.After(noConnectionTimeout):
}
sub.Unsubscribe()
err = sim.Net.ConnectNodesRing(nil) err = sim.Net.ConnectNodesRing(nil)
if err != nil { if err != nil {
return fmt.Errorf("connect nodes: %v", err) return fmt.Errorf("connect nodes: %v", err)

View file

@ -82,11 +82,10 @@ func getDbStore(nodeID string) (*state.DBStore, error) {
} }
var ( var (
nodeCount = flag.Int("nodes", 10, "number of nodes to create (default 10)") nodeCount = flag.Int("nodes", 10, "number of nodes to create (default 10)")
initCount = flag.Int("conns", 1, "number of originally connected peers (default 1)") initCount = flag.Int("conns", 1, "number of originally connected peers (default 1)")
loglevel = flag.Int("loglevel", 3, "verbosity of logs") loglevel = flag.Int("loglevel", 3, "verbosity of logs")
rawlog = flag.Bool("rawlog", false, "remove terminal formatting from logs") rawlog = flag.Bool("rawlog", false, "remove terminal formatting from logs")
serviceOverride = flag.String("services", "", "remove or add services to the node snapshot; prefix with \"+\" to add, \"-\" to remove; example: +pss,-discovery")
) )
func init() { func init() {