fix: NewTipSet: check mismatch in number of parents

This commit is contained in:
Lucas Molas 2020-07-15 08:17:50 -03:00
parent 99b5ec96a2
commit 21ffe188f4

View File

@ -112,6 +112,10 @@ func NewTipSet(blks []*BlockHeader) (*TipSet, error) {
return nil, fmt.Errorf("cannot create tipset with mismatching heights")
}
if len(blks[0].Parents) != len(b.Parents) {
return nil, fmt.Errorf("cannot create tipset with mismatching number of parents")
}
for i, cid := range b.Parents {
if cid != blks[0].Parents[i] {
return nil, fmt.Errorf("cannot create tipset with mismatching parents")