diff --git a/cmd/client/txgen/main.go b/cmd/client/txgen/main.go index d2e41c96f..884efe232 100644 --- a/cmd/client/txgen/main.go +++ b/cmd/client/txgen/main.go @@ -123,11 +123,7 @@ func main() { clientNode.Client = client.NewClient(clientNode.GetHost(), shardIDLeaderMap) readySignal := make(chan uint32) - go func() { - for i := range shardIDLeaderMap { - readySignal <- i - } - }() + // This func is used to update the client's blockchain when new blocks are received from the leaders updateBlocksFunc := func(blocks []*types.Block) { utils.GetLogInstance().Info("[Txgen] Received new block", "block", blocks) @@ -158,12 +154,18 @@ func main() { // Start the client server to listen to leader's message go clientNode.StartServer() - // wait for 1 seconds for client to send ping message to leader - time.Sleep(time.Second) clientNode.State = node.NodeReadyForConsensus + go func() { + // wait for 3 seconds for client to send ping message to leader + // FIXME (leo) the readySignal should be set once we really sent ping message to leader + time.Sleep(3 * time.Second) // wait for nodes to be ready + for i := range shardIDLeaderMap { + readySignal <- i + } + }() + // Transaction generation process - time.Sleep(5 * time.Second) // wait for nodes to be ready start := time.Now() totalTime := float64(*duration)