wip fixes

This commit is contained in:
Ethan Buchman 2018-06-04 12:37:37 -07:00 committed by ValarDragon
parent 47256cfda2
commit e79b642d8d
2 changed files with 20 additions and 4 deletions

View File

@ -132,6 +132,22 @@ func calculateStatistics(client tmrpc.Client, minHeight int64, timeStart, timeSt
os.Exit(1)
}
maxHeight := info.LastHeight
diff := maxHeight - minHeight
blockMetas := info.BlockMetas
offset := len(blockMetas)
for len(blockMetas) < int(diff) {
// get blocks between minHeight and last height
info, err := client.BlockchainInfo(minHeight+int64(offset), 0)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
blockMetas = append(blockMetas, info.BlockMetas...)
offset = len(blockMetas)
}
numBlocksPerSec := make(map[int64]int64)
numTxsPerSec := make(map[int64]int64)
// because during some seconds blocks won't be created...
@ -140,7 +156,7 @@ func calculateStatistics(client tmrpc.Client, minHeight int64, timeStart, timeSt
numTxsPerSec[i] = 0
}
for _, blockMeta := range info.BlockMetas {
for _, blockMeta := range blockMetas {
// check if block was created after timeStart
if blockMeta.Header.Time.Before(timeStart) {
continue
@ -174,6 +190,9 @@ func calculateStatistics(client tmrpc.Client, minHeight int64, timeStart, timeSt
stats.TxsThroughput.Update(n)
}
fmt.Println("blocks", numBlocksPerSec)
fmt.Println("txs", numTxsPerSec)
return stats
}

View File

@ -176,9 +176,6 @@ func (t *transacter) sendLoop(connIndex int) {
}
timeToSend := time.Now().Sub(startTime)
if timeToSend < 1*time.Second {
time.Sleep(time.Second - timeToSend)
}
logger.Info(fmt.Sprintf("sent %d transactions", t.Rate), "took", timeToSend)
case <-pingsTicker.C:
// go-rpc server closes the connection in the absence of pings