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

eth: conver if-else-if chain to tagged switch #27816

Merged
merged 1 commit into from
Jul 31, 2023
Merged
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
18 changes: 10 additions & 8 deletions eth/api_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ func (api *DebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error) {
return stateDb.RawDump(opts), nil
}
var header *types.Header
if blockNr == rpc.LatestBlockNumber {
switch blockNr {
case rpc.LatestBlockNumber:
header = api.eth.blockchain.CurrentBlock()
} else if blockNr == rpc.FinalizedBlockNumber {
case rpc.FinalizedBlockNumber:
header = api.eth.blockchain.CurrentFinalBlock()
} else if blockNr == rpc.SafeBlockNumber {
case rpc.SafeBlockNumber:
header = api.eth.blockchain.CurrentSafeBlock()
} else {
default:
block := api.eth.blockchain.GetBlockByNumber(uint64(blockNr))
if block == nil {
return state.Dump{}, fmt.Errorf("block #%d not found", blockNr)
Expand Down Expand Up @@ -146,13 +147,14 @@ func (api *DebugAPI) AccountRange(blockNrOrHash rpc.BlockNumberOrHash, start hex
}
} else {
var header *types.Header
if number == rpc.LatestBlockNumber {
switch number {
case rpc.LatestBlockNumber:
header = api.eth.blockchain.CurrentBlock()
} else if number == rpc.FinalizedBlockNumber {
case rpc.FinalizedBlockNumber:
header = api.eth.blockchain.CurrentFinalBlock()
} else if number == rpc.SafeBlockNumber {
case rpc.SafeBlockNumber:
header = api.eth.blockchain.CurrentSafeBlock()
} else {
default:
block := api.eth.blockchain.GetBlockByNumber(uint64(number))
if block == nil {
return state.IteratorDump{}, fmt.Errorf("block #%d not found", number)
Expand Down