mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 15:46:43 +00:00
adding block size metric
This commit is contained in:
parent
f481d9ca0f
commit
febf7e7f65
1 changed files with 9 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"io"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
|
|
@ -68,6 +69,8 @@ var (
|
|||
|
||||
diffInTurn = big.NewInt(2) // Block difficulty for in-turn signatures
|
||||
diffNoTurn = big.NewInt(1) // Block difficulty for out-of-turn signatures
|
||||
|
||||
blockSizeGaugeName = "clique/block_size_in_bytes"
|
||||
)
|
||||
|
||||
// Various error messages to mark blocks invalid. These should be private to
|
||||
|
|
@ -584,7 +587,12 @@ func (c *Clique) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
|
|||
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
|
||||
|
||||
// Assemble and return the final block for sealing.
|
||||
return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)), nil
|
||||
block := types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil))
|
||||
|
||||
if metrics.Enabled {
|
||||
metrics.GetOrRegisterGauge(blockSizeGaugeName, nil).Update(int64(block.Size()))
|
||||
}
|
||||
return block, nil
|
||||
}
|
||||
|
||||
// Authorize injects a private key into the consensus engine to mint new blocks
|
||||
|
|
|
|||
Loading…
Reference in a new issue