Merge branch 'master' into refactor_benchmark

pull/37/head
Minh Doan 6 years ago
commit 69fad674d5
  1. 14
      node/node_handler.go

@ -87,14 +87,26 @@ func (node *Node) NodeHandler(conn net.Conn) {
node.log.Debug("UtxoPool Report", "numEntries", len(node.UtxoPool.UtxoMap), "sizeInBytes", sizeInBytes) node.log.Debug("UtxoPool Report", "numEntries", len(node.UtxoPool.UtxoMap), "sizeInBytes", sizeInBytes)
avgBlockSizeInBytes := 0 avgBlockSizeInBytes := 0
txCount := 0
avgTxSize := 0
for _, block := range node.blockchain.Blocks { for _, block := range node.blockchain.Blocks {
byteBuffer := bytes.NewBuffer([]byte{}) byteBuffer := bytes.NewBuffer([]byte{})
encoder := gob.NewEncoder(byteBuffer) encoder := gob.NewEncoder(byteBuffer)
encoder.Encode(block) encoder.Encode(block)
avgBlockSizeInBytes += len(byteBuffer.Bytes()) avgBlockSizeInBytes += len(byteBuffer.Bytes())
txCount += len(block.Transactions)
byteBuffer = bytes.NewBuffer([]byte{})
encoder = gob.NewEncoder(byteBuffer)
encoder.Encode(block.Transactions)
avgTxSize += len(byteBuffer.Bytes())
} }
avgBlockSizeInBytes = avgBlockSizeInBytes / len(node.blockchain.Blocks) avgBlockSizeInBytes = avgBlockSizeInBytes / len(node.blockchain.Blocks)
node.log.Debug("Blockchain Report", "numBlocks", len(node.blockchain.Blocks), "avgSizeInBytes", avgBlockSizeInBytes) avgTxSize = avgTxSize / txCount
node.log.Debug("Blockchain Report", "numBlocks", len(node.blockchain.Blocks), "avgBlockSize", avgBlockSizeInBytes, "numTxs", txCount, "avgTxSzie", avgTxSize)
os.Exit(0) os.Exit(0)
} }

Loading…
Cancel
Save