From bc27867a749f1f8a344958126aaa881399fd0971 Mon Sep 17 00:00:00 2001 From: Goran Rojovic Date: Wed, 12 Apr 2023 15:16:33 +0200 Subject: [PATCH] Comments fix --- jsonrpc/eth_endpoint.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/jsonrpc/eth_endpoint.go b/jsonrpc/eth_endpoint.go index acccb5b006..a5f029037e 100644 --- a/jsonrpc/eth_endpoint.go +++ b/jsonrpc/eth_endpoint.go @@ -128,19 +128,10 @@ func (e *Eth) GetBlockByNumber(number BlockNumber, fullTx bool) (interface{}, er return nil, nil } - // we need to copy it because the store returns header from storage directly - // and not a copy, so changing it, actually changes it in storage as well - headerCopy := block.Header.Copy() - - filteredExtra, err := e.store.FilterExtra(headerCopy.ExtraData) - if err != nil { + if err := e.filterExtra(block); err != nil { return nil, err } - headerCopy.ExtraData = filteredExtra - // no need to recompute hash (filtered out data is not in the hash in the first place) - block.Header = headerCopy - return toBlock(block, fullTx), nil } @@ -151,20 +142,28 @@ func (e *Eth) GetBlockByHash(hash types.Hash, fullTx bool) (interface{}, error) return nil, nil } + if err := e.filterExtra(block); err != nil { + return nil, err + } + + return toBlock(block, fullTx), nil +} + +func (e *Eth) filterExtra(block *types.Block) error { // we need to copy it because the store returns header from storage directly // and not a copy, so changing it, actually changes it in storage as well headerCopy := block.Header.Copy() filteredExtra, err := e.store.FilterExtra(headerCopy.ExtraData) if err != nil { - return nil, err + return err } headerCopy.ExtraData = filteredExtra // no need to recompute hash (filtered out data is not in the hash in the first place) block.Header = headerCopy - return toBlock(block, fullTx), nil + return nil } func (e *Eth) GetBlockTransactionCountByNumber(number BlockNumber) (interface{}, error) {