From 70071e273d10f07010e70673f0d878fbb46f2262 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 27 Sep 2020 09:58:37 +0800 Subject: [PATCH 1/2] optimize tipset Equals func --- chain/types/tipset.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chain/types/tipset.go b/chain/types/tipset.go index 44d41c29d..5d34ec89d 100644 --- a/chain/types/tipset.go +++ b/chain/types/tipset.go @@ -167,6 +167,10 @@ func (ts *TipSet) Equals(ots *TipSet) bool { return false } + if ts.height != ots.height { + return false + } + if len(ts.blks) != len(ots.blks) { return false } From 04876c663e16eb381adb6695f32db1c7f99493ab Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Sun, 27 Sep 2020 10:17:06 +0800 Subject: [PATCH 2/2] modify tipset Equals --- chain/types/tipset.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chain/types/tipset.go b/chain/types/tipset.go index 5d34ec89d..07eff3734 100644 --- a/chain/types/tipset.go +++ b/chain/types/tipset.go @@ -171,12 +171,12 @@ func (ts *TipSet) Equals(ots *TipSet) bool { return false } - if len(ts.blks) != len(ots.blks) { + if len(ts.cids) != len(ots.cids) { return false } - for i, b := range ts.blks { - if b.Cid() != ots.blks[i].Cid() { + for i, cid := range ts.cids { + if cid != ots.cids[i] { return false } }