print multiple blocks from miner

This commit is contained in:
zgfzgf 2020-11-09 10:57:36 +08:00
parent f225b7b928
commit 8c8396af59

View File

@ -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") log.Debug("tried to add block to tipset tracker that was already there")
return nil 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()) 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) 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 { for _, bhc := range tsets {
if bhc == b.Cid() { if bhc == b.Cid() {
continue 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) return nil, xerrors.Errorf("failed to load block (%s) for tipset expansion: %w", bhc, err)
} }
if inclMiners[h.Miner] { if cid, found := inclMiners[h.Miner]; found {
log.Warnf("Have multiple blocks from miner %s at height %d in our tipset cache", h.Miner, h.Height) 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 continue
} }
if types.CidArrsEqual(h.Parents, b.Parents) { if types.CidArrsEqual(h.Parents, b.Parents) {
all = append(all, h) all = append(all, h)
inclMiners[h.Miner] = true inclMiners[h.Miner] = bhc
} }
} }