iotexproject / iotexproject/iotex-core

Implement HeaderByHeight in filedao

Open
#4,229 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
1.6k
Forks
382
Avg merge
4d 22h
Merged PRs (30d)
17

Description

### What would you like to be added
`HeaderByHeight`, which to be implemented in filedao_v2, should be used instead of `GetBlockByHeight` in https://github.com/iotexproject/iotex-core/blob/1791f82354c672631690e7b759de6bb51cb2a031/blockchain/filedao/filedao.go#L235

```Go
// Before
blk, err := v2.GetBlockByHeight(height)
// After
header, err := v2.HeaderByHeight(height)
```
### Why is this needed
Some queries can be optmized by HeaderByHeight
- https://github.com/iotexproject/iotex-core/blob/1791f82354c672631690e7b759de6bb51cb2a031/api/web3server.go#L850
- https://github.com/iotexproject/iotex-core/blob/1791f82354c672631690e7b759de6bb51cb2a031/chainservice/builder.go#L672

### How important you think this is for IoTeX
- [] must have
- [] should have
- [] nice to have

### Additional information
Let us know any background or context that would help us better understand the request (for example the particular use-case that prompted this request)

Contributor guide

Open the contributing guide

Research direction

Start by reading filedao/filedao.go at the referenced GetBlockByHeight call, then inspect the related query paths in api/web3server.go and chainservice/builder.go. Trace how filedao_v2 retrieves blocks and define the HeaderByHeight behavior needed by those callers. Done means the header-based lookup is implemented and the relevant block lookups use it without changing their results.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, blockchain
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.