statistics.go fix

This commit is contained in:
Marko Baricevic 2019-07-17 12:55:48 +02:00
parent 595587313c
commit c8d5b4c43a
2 changed files with 6 additions and 5 deletions

View File

@ -67,9 +67,8 @@ func calculateStatistics(
numBlocksPerSec[sec]++
// increase number of txs for that second
// TODO: add tracking for tx/sec
numTxsPerSec[sec] += 1
logger.Debug(fmt.Sprintf("%d txs at block height %d", 1, blockMeta.Header.Height))
numTxsPerSec[sec] += blockMeta.NumTxs
logger.Debug(fmt.Sprintf("%d txs at block height %d", blockMeta.NumTxs, blockMeta.Header.Height))
}
for i := int64(0); i < int64(duration); i++ {

View File

@ -2,8 +2,9 @@ package types
// BlockMeta contains meta information about a block - namely, it's ID and Header.
type BlockMeta struct {
BlockID BlockID `json:"block_id"` // the block hash and partsethash
Header Header `json:"header"` // The block's Header
BlockID BlockID `json:"block_id"` // the block hash and partsethash
Header Header `json:"header"` // The block's Header
NumTxs int64 `json:"number_txs"` //
}
// NewBlockMeta returns a new BlockMeta from the block and its blockParts.
@ -11,6 +12,7 @@ func NewBlockMeta(block *Block, blockParts *PartSet) *BlockMeta {
return &BlockMeta{
BlockID: BlockID{block.Hash(), blockParts.Header()},
Header: block.Header,
NumTxs: int64(len(block.Data.Txs)),
}
}