mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +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
|
// compact the slice's memory
|
||||||
ret := rewardFileNames[startIndex:endIndex]
|
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) {
|
func getEpochReward(account common.Address, header *types.Header) (AccountEpochReward, error) {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package vm
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"slices"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/XDCx/tradingstate"
|
"github.com/XinFinOrg/XDPoSChain/XDCx/tradingstate"
|
||||||
|
|
@ -170,20 +171,20 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, tradingStat
|
||||||
default:
|
default:
|
||||||
evm.table = &frontierInstructionSet
|
evm.table = &frontierInstructionSet
|
||||||
}
|
}
|
||||||
|
var extraEips []int
|
||||||
if len(evm.Config.ExtraEips) > 0 {
|
if len(evm.Config.ExtraEips) > 0 {
|
||||||
// Deep-copy jumptable to prevent modification of opcodes in other tables
|
// Deep-copy jumptable to prevent modification of opcodes in other tables
|
||||||
evm.table = copyJumpTable(evm.table)
|
evm.table = copyJumpTable(evm.table)
|
||||||
}
|
for _, eip := range evm.Config.ExtraEips {
|
||||||
extraEips := make([]int, 0, len(evm.Config.ExtraEips))
|
if err := EnableEIP(eip, evm.table); err != nil {
|
||||||
for _, eip := range evm.Config.ExtraEips {
|
// Disable it, so caller can check if it's activated or not
|
||||||
if err := EnableEIP(eip, evm.table); err != nil {
|
log.Error("EIP activation failed", "eip", eip, "error", err)
|
||||||
// Disable it, so caller can check if it's activated or not
|
} else {
|
||||||
log.Error("EIP activation failed", "eip", eip, "error", err)
|
extraEips = append(extraEips, eip)
|
||||||
} else {
|
}
|
||||||
extraEips = append(extraEips, eip)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
evm.Config.ExtraEips = extraEips[0:len(extraEips):len(extraEips)]
|
evm.Config.ExtraEips = slices.Clip(extraEips)
|
||||||
|
|
||||||
return evm
|
return evm
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue