eth: conver if-else-if chain to tagged switch (#27816)
This commit is contained in:
parent
95cc7bf4f8
commit
5a4eba6886
|
@ -62,13 +62,14 @@ func (api *DebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error) {
|
||||||
return stateDb.RawDump(opts), nil
|
return stateDb.RawDump(opts), nil
|
||||||
}
|
}
|
||||||
var header *types.Header
|
var header *types.Header
|
||||||
if blockNr == rpc.LatestBlockNumber {
|
switch blockNr {
|
||||||
|
case rpc.LatestBlockNumber:
|
||||||
header = api.eth.blockchain.CurrentBlock()
|
header = api.eth.blockchain.CurrentBlock()
|
||||||
} else if blockNr == rpc.FinalizedBlockNumber {
|
case rpc.FinalizedBlockNumber:
|
||||||
header = api.eth.blockchain.CurrentFinalBlock()
|
header = api.eth.blockchain.CurrentFinalBlock()
|
||||||
} else if blockNr == rpc.SafeBlockNumber {
|
case rpc.SafeBlockNumber:
|
||||||
header = api.eth.blockchain.CurrentSafeBlock()
|
header = api.eth.blockchain.CurrentSafeBlock()
|
||||||
} else {
|
default:
|
||||||
block := api.eth.blockchain.GetBlockByNumber(uint64(blockNr))
|
block := api.eth.blockchain.GetBlockByNumber(uint64(blockNr))
|
||||||
if block == nil {
|
if block == nil {
|
||||||
return state.Dump{}, fmt.Errorf("block #%d not found", blockNr)
|
return state.Dump{}, fmt.Errorf("block #%d not found", blockNr)
|
||||||
|
@ -146,13 +147,14 @@ func (api *DebugAPI) AccountRange(blockNrOrHash rpc.BlockNumberOrHash, start hex
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var header *types.Header
|
var header *types.Header
|
||||||
if number == rpc.LatestBlockNumber {
|
switch number {
|
||||||
|
case rpc.LatestBlockNumber:
|
||||||
header = api.eth.blockchain.CurrentBlock()
|
header = api.eth.blockchain.CurrentBlock()
|
||||||
} else if number == rpc.FinalizedBlockNumber {
|
case rpc.FinalizedBlockNumber:
|
||||||
header = api.eth.blockchain.CurrentFinalBlock()
|
header = api.eth.blockchain.CurrentFinalBlock()
|
||||||
} else if number == rpc.SafeBlockNumber {
|
case rpc.SafeBlockNumber:
|
||||||
header = api.eth.blockchain.CurrentSafeBlock()
|
header = api.eth.blockchain.CurrentSafeBlock()
|
||||||
} else {
|
default:
|
||||||
block := api.eth.blockchain.GetBlockByNumber(uint64(number))
|
block := api.eth.blockchain.GetBlockByNumber(uint64(number))
|
||||||
if block == nil {
|
if block == nil {
|
||||||
return state.IteratorDump{}, fmt.Errorf("block #%d not found", number)
|
return state.IteratorDump{}, fmt.Errorf("block #%d not found", number)
|
||||||
|
|
Loading…
Reference in New Issue