mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
core, consensus: use slice.Clip capacity to Simplify code (#1892)
This commit is contained in:
parent
fb89c95640
commit
2855f1b48c
2 changed files with 11 additions and 10 deletions
|
|
@ -580,7 +580,7 @@ func (api *API) getRewardFileNamesInRange(begin, end *rpc.BlockNumber) ([]reward
|
|||
|
||||
// compact the slice's memory
|
||||
ret := rewardFileNames[startIndex:endIndex]
|
||||
return ret[:len(ret):len(ret)], nil
|
||||
return slices.Clip(ret), nil
|
||||
}
|
||||
|
||||
func getEpochReward(account common.Address, header *types.Header) (AccountEpochReward, error) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package vm
|
|||
import (
|
||||
"errors"
|
||||
"math/big"
|
||||
"slices"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/XDCx/tradingstate"
|
||||
|
|
@ -170,20 +171,20 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, tradingStat
|
|||
default:
|
||||
evm.table = &frontierInstructionSet
|
||||
}
|
||||
var extraEips []int
|
||||
if len(evm.Config.ExtraEips) > 0 {
|
||||
// Deep-copy jumptable to prevent modification of opcodes in other tables
|
||||
evm.table = copyJumpTable(evm.table)
|
||||
}
|
||||
extraEips := make([]int, 0, len(evm.Config.ExtraEips))
|
||||
for _, eip := range evm.Config.ExtraEips {
|
||||
if err := EnableEIP(eip, evm.table); err != nil {
|
||||
// Disable it, so caller can check if it's activated or not
|
||||
log.Error("EIP activation failed", "eip", eip, "error", err)
|
||||
} else {
|
||||
extraEips = append(extraEips, eip)
|
||||
for _, eip := range evm.Config.ExtraEips {
|
||||
if err := EnableEIP(eip, evm.table); err != nil {
|
||||
// Disable it, so caller can check if it's activated or not
|
||||
log.Error("EIP activation failed", "eip", eip, "error", err)
|
||||
} else {
|
||||
extraEips = append(extraEips, eip)
|
||||
}
|
||||
}
|
||||
}
|
||||
evm.Config.ExtraEips = extraEips[0:len(extraEips):len(extraEips)]
|
||||
evm.Config.ExtraEips = slices.Clip(extraEips)
|
||||
|
||||
return evm
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue