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

server: Use HeaderByNumber() instead of BlockByNumber() in the function requesting LPT from faucet #2550

Merged
merged 2 commits into from
Aug 1, 2022
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
3 changes: 2 additions & 1 deletion CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
#### CLI

#### General
- [#2550](https://github.com/livepeer/go-livepeer/pull/2550) Fix requesting LPT from faucet after the Nitro migration (@leszko)

#### Broadcaster

- [#2541](https://github.com/livepeer/go-livepeer/pull/2541) Enforce a minimum
- [#2541](https://github.com/livepeer/go-livepeer/pull/2541) Enforce a minimum
timeout for segment upload (@victorges)

#### Orchestrator
Expand Down
4 changes: 2 additions & 2 deletions server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,13 +1029,13 @@ func requestTokensHandler(client eth.LivepeerEthClient) http.Handler {
}

backend := client.Backend()
blk, err := backend.BlockByNumber(r.Context(), nil)
h, err := backend.HeaderByNumber(r.Context(), nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to only fetch the block header as opposed to the entire block here anyway because we don't care about most of the data in the block anyway and we can just get the information we need from the slimmer header.

if err != nil {
respond500(w, fmt.Sprintf("Unable to get latest block: %v", err))
return
}

now := int64(blk.Time())
now := int64(h.Time)
if nextValidRequest.Int64() != 0 && nextValidRequest.Int64() > now {
respond500(w, fmt.Sprintf("Error requesting tokens from faucet: can only request tokens once every hour, please wait %v more minutes", (nextValidRequest.Int64()-now)/60))
return
Expand Down