From ee7cab34a6924ebb8a2b915604a3e4a347e9fe48 Mon Sep 17 00:00:00 2001 From: wizeguyy Date: Thu, 3 Oct 2024 11:32:41 -0500 Subject: [PATCH 1/3] Remove obsolete getHeaderHashByNumber --- internal/quaiapi/quai_api.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/internal/quaiapi/quai_api.go b/internal/quaiapi/quai_api.go index c0bac75f9..cb597900d 100644 --- a/internal/quaiapi/quai_api.go +++ b/internal/quaiapi/quai_api.go @@ -238,15 +238,6 @@ func (s *PublicBlockChainQuaiAPI) GetHeaderByNumber(ctx context.Context, number return nil, err } -// GetHeaderByHash returns the requested header by hash. -func (s *PublicBlockChainQuaiAPI) GetHeaderHashByNumber(ctx context.Context, number rpc.BlockNumber) common.Hash { - header, err := s.b.HeaderByNumber(ctx, number) - if err != nil { - return common.Hash{} - } - return header.Hash() -} - // GetHeaderByHash returns the requested header by hash. func (s *PublicBlockChainQuaiAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{} { header, _ := s.b.HeaderByHash(ctx, hash) From 21a48f4c9944b9aed620d82cf329a7150df31bd0 Mon Sep 17 00:00:00 2001 From: wizeguyy Date: Thu, 3 Oct 2024 11:43:04 -0500 Subject: [PATCH 2/3] Fix response for BlockByNumber not found --- quai/api_backend.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/quai/api_backend.go b/quai/api_backend.go index 7e4997de0..631bdebd8 100644 --- a/quai/api_backend.go +++ b/quai/api_backend.go @@ -127,11 +127,7 @@ func (b *QuaiAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumb if number == rpc.LatestBlockNumber { number = rpc.BlockNumber(b.quai.core.CurrentHeader().NumberU64(b.NodeCtx())) } - block := b.quai.core.GetBlockByNumber(uint64(number)) - if block != nil { - return block, nil - } - return nil, errors.New("block is nil api backend") + return b.quai.core.GetBlockByNumber(uint64(number)), nil } func (b *QuaiAPIBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.WorkObject, error) { From 4520d1704f9dd9253403faa98dc464e8be38abe5 Mon Sep 17 00:00:00 2001 From: wizeguyy Date: Thu, 3 Oct 2024 11:46:54 -0500 Subject: [PATCH 3/3] Fix response for getBlockOrCandidateByHash --- internal/quaiapi/quai_api.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/quaiapi/quai_api.go b/internal/quaiapi/quai_api.go index cb597900d..ff6445ade 100644 --- a/internal/quaiapi/quai_api.go +++ b/internal/quaiapi/quai_api.go @@ -281,11 +281,10 @@ func (s *PublicBlockChainQuaiAPI) GetBlockByHash(ctx context.Context, hash commo } func (s *PublicBlockChainQuaiAPI) GetBlockOrCandidateByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error) { - block := s.b.BlockOrCandidateByHash(hash) - if block != nil { + if block := s.b.BlockOrCandidateByHash(hash); block != nil { return s.rpcMarshalBlock(ctx, block, true, fullTx) } - return nil, errors.New("block not found") + return nil, nil } // GetUncleByBlockNumberAndIndex returns the uncle block for the given block hash and index. When fullTx is true