diff --git a/internal/quaiapi/quai_api.go b/internal/quaiapi/quai_api.go index c0bac75f9..ff6445ade 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) @@ -290,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 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) {