func startStop(net *Network, quit chan struct{}, nodeCount int) {
	nodes, err := connectNodesInRing(net, nodeCount)
	if err != nil {
		panic("Could not startup node network for mocker")
	}
	tick := time.NewTicker(10 * time.Second)
	defer tick.Stop()
	for {
		select {
		case <-quit:
			log.Info("Terminating simulation loop")
			return
		case <-tick.C:
			id := nodes[rand.Intn(len(nodes))]
			log.Info("stopping node", "id", id)
			if err := net.Stop(id); err != nil {
				log.Error("error stopping node", "id", id, "err", err)
				return
			}

			select {
			case <-quit:
				log.Info("Terminating simulation loop")
				return
			case <-time.After(3 * time.Second):
			}

			log.Debug("starting node", "id", id)
			if err := net.Start(id); err != nil {
				log.Error("error starting node", "id", id, "err", err)
				return
			}
		}
	}
}
//The startStop mockerFn stops and starts nodes in a defined period (ticker)
The startStop mockerFn stops and starts nodes in a defined period (ticker)
// The startStop mockerFn stops and starts nodes in a defined period ( ticker )
func startStop(net *Network, quit chan struct{}, nodeCount int) {
	nodes, err := connectNodesInRing(net, nodeCount)
	if err != nil {
		panic("Could not startup node network for mocker")
	}
	tick := time.NewTicker(10 * time.Second)
	defer tick.Stop()
	for {
		select {
		case <-quit:
			log.Info("Terminating simulation loop")
			return
		case <-tick.C:
			id := nodes[rand.Intn(len(nodes))]
			log.Info("stopping node", "id", id)
			if err := net.Stop(id); err != nil {
				log.Error("error stopping node", "id", id, "err", err)
				return
			}
			select {
			case <-quit:
				log.Info("Terminating simulation loop")
				return
			case <-time.After(3 * time.Second):
			}
			log.Debug("starting node", "id", id)
			if err := net.Start(id); err != nil {
				log.Error("error starting node", "id", id, "err", err)
				return
			}
		}
	}
}
func startStop ( net * Network , quit chan struct { } , nodeCount int ) { nodes , err := connectNodesInRing ( net , nodeCount ) if err != nil { panic ( " " ) } tick := time . NewTicker ( 10 * time . Second ) defer tick . Stop ( ) for { select { case <- quit : log . Info ( " " ) return case <- tick . C : id := nodes [ rand . Intn ( len ( nodes ) ) ] log . Info ( " " , " " , id ) if err := net . Stop ( id ) ; err != nil { log . Error ( " " , " " , id , " " , err ) return } select { case <- quit : log . Info ( " " ) return case <- time . After ( 3 * time . Second ) : } log . Debug ( " " , " " , id ) if err := net . Start ( id ) ; err != nil { log . Error ( " " , " " , id , " " , err ) return } } } }
The startStop mockerFn stops and starts nodes in a defined period (ticker)
The startStop mockerFn stops and starts nodes in a defined period ( ticker )