rpc: remove duplication of data in ResultBlock (#3856)

## Issue:

    Removed BlockMeta in ResultBlock in favor of BlockId for /block
    Added block_size to BlockMeta this is reflected in /blockchain

fixes #3188

added breaking as some clients may be using header from blockmeta instead of block in /block

## Commits:

* cleanup block path

Remove duplication of data in `/block`

fixes #3188

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* Remove duplication of data in `/block`

- Created a secondary type to be used for /block

fixes #3188

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* remove commented out code

* fix ci

* add changelog_pending entry

* remove extra variable

* update swagger

* change int to uint for blocksize

* fix swagger

* remove extensive comments

* update changelog

* fix conflicts after merge

* use int for BlockSize and NumTxs in BlockMeta

- with 99.9% guarantee, the size of either will never reach int32
- most of the Go "Size" stdlib functions return int
This commit is contained in:
Marko
2019-11-14 14:46:44 +04:00
committed by Anton Kaliaev
parent 1604047c39
commit 41403d5261
8 changed files with 37 additions and 35 deletions
+8 -8
View File
@@ -35,12 +35,12 @@ func calculateStatistics(
}
var (
numBlocksPerSec = make(map[int64]int64)
numTxsPerSec = make(map[int64]int64)
numBlocksPerSec = make(map[int]int)
numTxsPerSec = make(map[int]int)
)
// because during some seconds blocks won't be created...
for i := int64(0); i < int64(duration); i++ {
for i := 0; i < duration; i++ {
numBlocksPerSec[i] = 0
numTxsPerSec[i] = 0
}
@@ -71,9 +71,9 @@ func calculateStatistics(
logger.Debug(fmt.Sprintf("%d txs at block height %d", blockMeta.NumTxs, blockMeta.Header.Height))
}
for i := int64(0); i < int64(duration); i++ {
stats.BlocksThroughput.Update(numBlocksPerSec[i])
stats.TxsThroughput.Update(numTxsPerSec[i])
for i := 0; i < duration; i++ {
stats.BlocksThroughput.Update(int64(numBlocksPerSec[i]))
stats.TxsThroughput.Update(int64(numTxsPerSec[i]))
}
return stats, nil
@@ -107,8 +107,8 @@ func getBlockMetas(client tmrpc.Client, minHeight int64, timeStart, timeEnd time
return blockMetas, nil
}
func secondsSinceTimeStart(timeStart, timePassed time.Time) int64 {
return int64(math.Round(timePassed.Sub(timeStart).Seconds()))
func secondsSinceTimeStart(timeStart, timePassed time.Time) int {
return int(math.Round(timePassed.Sub(timeStart).Seconds()))
}
func printStatistics(stats *statistics, outputFormat string) {