From 3982888562262cb9c19146166f977b109502857c Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 5 May 2025 09:34:26 +0200 Subject: [PATCH] core/block: add BlobCount function Signed-off-by: Csaba Kiraly --- core/types/block.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/types/block.go b/core/types/block.go index b284fb3b16..919008a123 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-verkle" ) @@ -367,6 +368,13 @@ func (b *Block) Uncles() []*Header { return b.uncles } func (b *Block) Transactions() Transactions { return b.transactions } func (b *Block) Withdrawals() Withdrawals { return b.withdrawals } +func (b *Block) BlobCount() uint64 { + if b.header.BlobGasUsed == nil { + return 0 + } + return *b.header.BlobGasUsed / params.BlobTxBlobGasPerBlob +} + func (b *Block) Transaction(hash common.Hash) *Transaction { for _, transaction := range b.transactions { if transaction.Hash() == hash {