Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rpc inconsistencies #2185

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions internal/quaiapi/quai_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions quai/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading