Skip to content

Commit

Permalink
make user tipst Do NOT include more than one blocks mined by a miner
Browse files Browse the repository at this point in the history
  • Loading branch information
zl03jsj committed Feb 28, 2022
1 parent 4044c8f commit 92d841b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/chainsync/types/target_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"container/list"
"github.com/filecoin-project/go-address"
"sort"
"strconv"
"sync"
Expand Down Expand Up @@ -258,6 +259,8 @@ func (tq *TargetTracker) widen(t *Target) (*Target, bool) {
}
}

miners := make(map[address.Address]interface{})

//collect neighbor block in queue include history to get block with same weight and height
sameWeightBlks := make(map[cid.Cid]*types.BlockHeader)
for _, val := range tq.targetSet {
Expand All @@ -266,7 +269,13 @@ func (tq *TargetTracker) widen(t *Target) (*Target, bool) {
bid := blk.Cid()
if !t.Head.Key().Has(bid) {
if _, ok := sameWeightBlks[bid]; !ok {
if _, isok := miners[blk.Miner]; isok {
// TODO: a miner mined more than one blocks ?
log.Warnf("miner : %s mined more than one blocks, this is illegal", blk.Miner.String())
return nil, false
}
sameWeightBlks[bid] = blk
miners[blk.Miner] = nil
}
}
}
Expand Down

0 comments on commit 92d841b

Please sign in to comment.