core/block: add BlobCount function

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-05-05 09:34:26 +02:00
parent b135da2eac
commit 3982888562
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E

View file

@ -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 {