Merge pull request #849 from alajko/txfix

Fixing TXGen
pull/856/head
alajko 6 years ago committed by GitHub
commit 3f6707a077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      cmd/client/txgen/main.go

@ -62,7 +62,7 @@ var (
port = flag.String("port", "9999", "port of the node.") port = flag.String("port", "9999", "port of the node.")
maxNumTxsPerBatch = flag.Int("max_num_txs_per_batch", 20000, "number of transactions to send per message") maxNumTxsPerBatch = flag.Int("max_num_txs_per_batch", 20000, "number of transactions to send per message")
logFolder = flag.String("log_folder", "latest", "the folder collecting the logs of this execution") logFolder = flag.String("log_folder", "latest", "the folder collecting the logs of this execution")
duration = flag.Int("duration", 10, "duration of the tx generation in second. If it's negative, the experiment runs forever.") duration = flag.Int("duration", 30, "duration of the tx generation in second. If it's negative, the experiment runs forever.")
versionFlag = flag.Bool("version", false, "Output version info") versionFlag = flag.Bool("version", false, "Output version info")
crossShardRatio = flag.Int("cross_shard_ratio", 30, "The percentage of cross shard transactions.") //Keeping this for backward compatibility crossShardRatio = flag.Int("cross_shard_ratio", 30, "The percentage of cross shard transactions.") //Keeping this for backward compatibility
shardIDFlag = flag.Int("shardID", 0, "The shardID the node belongs to.") shardIDFlag = flag.Int("shardID", 0, "The shardID the node belongs to.")
@ -157,6 +157,7 @@ func main() {
time.Sleep(20 * time.Second) time.Sleep(20 * time.Second)
start := time.Now() start := time.Now()
totalTime := float64(*duration) totalTime := float64(*duration)
utils.GetLogInstance().Debug("Total Duration", "totalTime", totalTime)
ticker := time.NewTicker(checkFrequency * time.Second) ticker := time.NewTicker(checkFrequency * time.Second)
txGen.DoSyncWithoutConsensus() txGen.DoSyncWithoutConsensus()
syncLoop: syncLoop:
@ -201,11 +202,13 @@ syncLoop:
time.Sleep(3 * time.Second) // wait for nodes to be ready time.Sleep(3 * time.Second) // wait for nodes to be ready
readySignal <- uint32(0) readySignal <- uint32(0)
}() }()
pushLoop:
for { for {
t := time.Now() t := time.Now()
utils.GetLogInstance().Debug("Current running time", "running time", t.Sub(start).Seconds(), "totaltime", totalTime)
if totalTime > 0 && t.Sub(start).Seconds() >= totalTime { if totalTime > 0 && t.Sub(start).Seconds() >= totalTime {
utils.GetLogInstance().Debug("Generator timer ended.", "duration", (int(t.Sub(start))), "startTime", start, "totalTime", totalTime) utils.GetLogInstance().Debug("Generator timer ended.", "duration", (int(t.Sub(start))), "startTime", start, "totalTime", totalTime)
break break pushLoop
} }
select { select {
case shardID := <-readySignal: case shardID := <-readySignal:
@ -222,11 +225,6 @@ syncLoop:
utils.GetLogInstance().Warn("No new block is received so far") utils.GetLogInstance().Warn("No new block is received so far")
} }
} }
// Send a stop message to stop the nodes at the end
msg := proto_node.ConstructStopMessage()
txGen.GetHost().SendMessageToGroups([]p2p.GroupID{p2p.GroupIDBeaconClient}, p2p_host.ConstructP2pMessage(byte(0), msg))
time.Sleep(3 * time.Second)
} }
// SendTxsToShard sends txs to shard, currently just to beacon shard // SendTxsToShard sends txs to shard, currently just to beacon shard

Loading…
Cancel
Save