看了下共识使用了 dpos,但是我不太懂,选择打包者这块的代码是什么意思? 代码如下, 知道或者看懂的同学,请指导下(谢谢). 源码位置: https://github.com/meitu/go-ethereum/blob/6be4cd4b94f22b2cea34086bf0aa9752dd4ebf15/consensus/dpos/epoch_context.go#L129.
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
}