看了共识使用了dpos ,但是我不太懂,选择打包者这块的代码是什么意思? 代码如下, 知道或者看懂的同学,请指导下。源码位置:
https://github.com/meitu/go-e...
func (ec *EpochContext) lookupValidator(now int64) (validator common.Address, err error) {
validator = common.Address{}
offset := now % epochInterval // 这个为什么要先这个样子做,
if offset%blockInterval != 0 {
return common.Address{}, ErrInvalidMintBlockTime
}
offset /= blockInterval
validators, err := ec.DposContext.GetValidators()
if err != nil {
return common.Address{}, err
}
validatorSize := len(validators)
if validatorSize == 0 {
return common.Address{}, errors.New("failed to lookup validator")
}
offset %= int64(validatorSize)
return validators[offset], nil
}