adding block size metric in both worker and clique.go files

This commit is contained in:
kant 2023-11-30 17:41:32 -08:00
parent ce59a9b6a1
commit bbc42f5279
2 changed files with 6 additions and 6 deletions

View file

@ -589,8 +589,6 @@ func (c *Clique) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
// Assemble and return the final block for sealing.
block := types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil))
fmt.Println("*************CLIQUE*************************************")
fmt.Printf("clique.go block_size_in_bytes: %v\n", int64(block.Size()))
if metrics.Enabled {
metrics.GetOrRegisterGauge(blockSizeGaugeName, nil).Update(int64(block.Size()))
}

View file

@ -19,6 +19,7 @@ package miner
import (
"errors"
"fmt"
"github.com/ethereum/go-ethereum/metrics"
"math/big"
"sync"
"sync/atomic"
@ -77,6 +78,8 @@ var (
errBlockInterruptedByNewHead = errors.New("new head arrived while building block")
errBlockInterruptedByRecommit = errors.New("recommit interrupt while building block")
errBlockInterruptedByTimeout = errors.New("timeout while building block")
blockSizeGaugeName = "clique/block_size_in_bytes"
)
// environment is the worker's current environment and holds all
@ -1122,10 +1125,9 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti
env := env.copy()
// Withdrawals are set to nil here, because this is only called in PoW.
block, err := w.engine.FinalizeAndAssemble(w.chain, env.header, env.state, env.txs, nil, env.receipts, nil)
//log.PrintOrigins(true)
//log.Info(fmt.Sprintf("block_size_in_bytes: %v", int64(block.Size())))
fmt.Println("********************************************************")
fmt.Printf("block_size_in_bytes: %v\n", int64(block.Size()))
if metrics.Enabled {
metrics.GetOrRegisterGauge(blockSizeGaugeName, nil).Update(int64(block.Size()))
}
if err != nil {
return err
}