Skip to content

Commit

Permalink
fix: select error node
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin committed Feb 1, 2023
1 parent e07dba4 commit 8f64621
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
3 changes: 0 additions & 3 deletions co/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func (c *Coordinator) handleCandidate(hc *headCandidate) {

if c.sel.Weight(addr) == 0 {
log.Infof("skip zero weight node %s ", addr)
hc.done()
return
}
clog := log.With("node", addr, "h", hc.ts.Height(), "w", hc.weight, "drift", time.Now().Unix()-int64(hc.ts.MinTimestamp()))
Expand All @@ -99,7 +98,6 @@ func (c *Coordinator) handleCandidate(hc *headCandidate) {
next := hc.ts

c.head = hc.ts
hc.done() //cache update must after set head
c.weight = hc.weight
c.nodes = append(c.nodes[:0], addr)

Expand All @@ -120,7 +118,6 @@ func (c *Coordinator) handleCandidate(hc *headCandidate) {
return
}

defer hc.done() //update cache although this head is not the best
if c.head.Equals(hc.ts) {
contains := false
for ni := range c.nodes {
Expand Down
1 change: 0 additions & 1 deletion co/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type headCandidate struct {
node *Node
ts *types.TipSet
weight types.BigInt
done func()
}

func newBlockHeaderCache(size int) (*blockHeaderCache, error) {
Expand Down
5 changes: 2 additions & 3 deletions co/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ func (n *Node) reListen() (<-chan []*api.HeadChange, error) {
}

func (n *Node) applyChanges(lifeCtx context.Context, changes []*api.HeadChange) {
n.blkCache.add(changes)

idx := -1
for i := range changes {
switch changes[i].Type {
Expand Down Expand Up @@ -240,9 +242,6 @@ func (n *Node) applyChanges(lifeCtx context.Context, changes []*api.HeadChange)
node: n,
ts: ts,
weight: weight,
done: func() {
n.blkCache.add(changes)
},
}

slow := time.NewTicker(5 * time.Second)
Expand Down

0 comments on commit 8f64621

Please sign in to comment.