From 6c4537f6a85417ab68ea91009c3315b7415390da Mon Sep 17 00:00:00 2001 From: hans Date: Mon, 28 Oct 2019 17:19:58 +0800 Subject: [PATCH] fix NewTipSet --- chain/types/tipset.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/chain/types/tipset.go b/chain/types/tipset.go index 3733a6f09..40b2b2b0b 100644 --- a/chain/types/tipset.go +++ b/chain/types/tipset.go @@ -74,9 +74,15 @@ func NewTipSet(blks []*BlockHeader) (*TipSet, error) { if b.Height != blks[0].Height { return nil, fmt.Errorf("cannot create tipset with mismatching heights") } + + for i, cid := range b.Parents { + if cid != blks[0].Parents[i] { + return nil, fmt.Errorf("cannot create tipset with mismatching parents") + } + } + ts.cids = append(ts.cids, b.Cid()) - // TODO: ensure the same parents } ts.height = blks[0].Height