mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 19:30:44 +00:00
fix: staticcheck warning SA4003: every value of uint64 >= 0
This commit is contained in:
parent
7b7eb91fcb
commit
f9960875cc
3 changed files with 111 additions and 113 deletions
|
|
@ -30,7 +30,7 @@ func AttachConsensusV1Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
|
|||
log.Crit("Can't get state at head of canonical chain", "head number", bc.CurrentHeader().Number.Uint64(), "err", err)
|
||||
}
|
||||
prevEpoc := blockNumberEpoc - chain.Config().XDPoS.Epoch
|
||||
if prevEpoc >= 0 {
|
||||
|
||||
start := time.Now()
|
||||
prevHeader := chain.GetHeaderByNumber(prevEpoc)
|
||||
penSigners := adaptor.GetMasternodes(chain, prevHeader)
|
||||
|
|
@ -65,8 +65,7 @@ func AttachConsensusV1Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
|
|||
}
|
||||
log.Debug("Time Calculated HookPenalty ", "block", blockNumberEpoc, "time", common.PrettyDuration(time.Since(start)))
|
||||
return penSigners, nil
|
||||
}
|
||||
return []common.Address{}, nil
|
||||
|
||||
}
|
||||
|
||||
// Hook scans for bad masternodes and decide to penalty them
|
||||
|
|
@ -77,7 +76,7 @@ func AttachConsensusV1Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
|
|||
if header.Number.Uint64() > comebackLength {
|
||||
combackEpoch = header.Number.Uint64() - comebackLength
|
||||
}
|
||||
if prevEpoc >= 0 {
|
||||
|
||||
start := time.Now()
|
||||
|
||||
listBlockHash := make([]common.Hash, chain.Config().XDPoS.Epoch)
|
||||
|
|
@ -173,10 +172,9 @@ func AttachConsensusV1Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
|
|||
if chain.Config().IsTIPRandomize(header.Number) {
|
||||
return penalties, nil
|
||||
}
|
||||
|
||||
return penComebacks, nil
|
||||
}
|
||||
return []common.Address{}, nil
|
||||
}
|
||||
|
||||
// Hook prepares validators M2 for the current epoch at checkpoint block
|
||||
adaptor.EngineV1.HookValidator = func(header *types.Header, signers []common.Address) ([]byte, error) {
|
||||
|
|
|
|||
|
|
@ -1230,7 +1230,7 @@ func (net *Network) checkTopicRegister(data *topicRegister) (*pong, error) {
|
|||
if rlpHash(data.Topics) != pongpkt.data.(*pong).TopicHash {
|
||||
return nil, errors.New("topic hash mismatch")
|
||||
}
|
||||
if data.Idx < 0 || int(data.Idx) >= len(data.Topics) {
|
||||
if int(data.Idx) >= len(data.Topics) {
|
||||
return nil, errors.New("topic index out of range")
|
||||
}
|
||||
return pongpkt.data.(*pong), nil
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ var (
|
|||
|
||||
func (i nodeEvent) String() string {
|
||||
switch {
|
||||
case 0 <= i && i <= 8:
|
||||
case i <= 8:
|
||||
return _nodeEvent_name_0[_nodeEvent_index_0[i]:_nodeEvent_index_0[i+1]]
|
||||
case 265 <= i && i <= 267:
|
||||
i -= 265
|
||||
|
|
|
|||
Loading…
Reference in a new issue