From 8c8396af5950a326626c3e31ba4e62f2f0e30cc3 Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Mon, 9 Nov 2020 10:57:36 +0800 Subject: [PATCH] print multiple blocks from miner --- chain/store/store.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/chain/store/store.go b/chain/store/store.go index 8a286f248..c41ef853b 100644 --- a/chain/store/store.go +++ b/chain/store/store.go @@ -651,6 +651,12 @@ func (cs *ChainStore) AddToTipSetTracker(b *types.BlockHeader) error { log.Debug("tried to add block to tipset tracker that was already there") return nil } + h, err := cs.GetBlock(oc) + if err == nil && h != nil { + if h.Miner == b.Miner { + log.Warnf("Have multiple blocks from miner %s at height %d in our tipset cache %s-%s", b.Miner, b.Height, b.Cid(), h.Cid()) + } + } } cs.tipsets[b.Height] = append(tss, b.Cid()) @@ -722,7 +728,7 @@ func (cs *ChainStore) expandTipset(b *types.BlockHeader) (*types.TipSet, error) return types.NewTipSet(all) } - inclMiners := map[address.Address]bool{b.Miner: true} + inclMiners := map[address.Address]cid.Cid{b.Miner: b.Cid()} for _, bhc := range tsets { if bhc == b.Cid() { continue @@ -733,14 +739,14 @@ func (cs *ChainStore) expandTipset(b *types.BlockHeader) (*types.TipSet, error) return nil, xerrors.Errorf("failed to load block (%s) for tipset expansion: %w", bhc, err) } - if inclMiners[h.Miner] { - log.Warnf("Have multiple blocks from miner %s at height %d in our tipset cache", h.Miner, h.Height) + if cid, found := inclMiners[h.Miner]; found { + log.Warnf("Have multiple blocks from miner %s at height %d in our tipset cache %s-%s", h.Miner, h.Height, h.Cid(), cid) continue } if types.CidArrsEqual(h.Parents, b.Parents) { all = append(all, h) - inclMiners[h.Miner] = true + inclMiners[h.Miner] = bhc } }