From 05070803a897361b502cb0e98d2be9154a8a6346 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Mon, 11 Sep 2023 22:19:09 +0800 Subject: [PATCH] graphql: add blobGasUsed,excessBlobGas for block Signed-off-by: jsvisa --- graphql/graphql.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/graphql/graphql.go b/graphql/graphql.go index 3574c4a2de..8304a64cf4 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -1067,6 +1067,30 @@ func (b *Block) Withdrawals(ctx context.Context) (*[]*Withdrawal, error) { return &ret, nil } +func (b *Block) BlobGasUsed(ctx context.Context) (*hexutil.Uint64, error) { + header, err := b.resolveHeader(ctx) + if err != nil { + return nil, err + } + if header.BlobGasUsed == nil { + return nil, nil + } + ret := hexutil.Uint64(*header.BlobGasUsed) + return &ret, nil +} + +func (b *Block) ExcessBlobGas(ctx context.Context) (*hexutil.Uint64, error) { + header, err := b.resolveHeader(ctx) + if err != nil { + return nil, err + } + if header.ExcessBlobGas == nil { + return nil, nil + } + ret := hexutil.Uint64(*header.ExcessBlobGas) + return &ret, nil +} + // BlockFilterCriteria encapsulates criteria passed to a `logs` accessor inside // a block. type BlockFilterCriteria struct {