trim m2 set to fit m1 set

This commit is contained in:
AnilChinchawale 2018-11-06 18:16:36 +05:30
parent b8cb19732f
commit 823cd1e6ef

View file

@ -564,10 +564,12 @@ func GetM1M2FromCheckpointBlock(checkpointBlock *types.Block) (map[common.Addres
validators := ExtractValidatorsFromBytes(checkpointBlock.Header().Validators)
if len(validators) < len(masternodes) {
return nil, errors.New("Len(m2) is less than len(m1)")
return nil, errors.New("len(m2) is less than len(m1)")
}
for i, m1 := range masternodes {
m1m2[m1] = masternodes[validators[i]]
if len(masternodes) > 0 {
for i, m1 := range masternodes {
m1m2[m1] = masternodes[validators[i]%int64(len(masternodes))]
}
}
return m1m2, nil
}