Skip to content

Commit

Permalink
use BFT threshold to check node catch up
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricfung committed Mar 18, 2019
1 parent 7a68bf3 commit b5ba9f0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions kernel/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (node *Node) UpdateSyncPoint(peerId crypto.Hash, points []*network.SyncPoin
}

func (node *Node) CheckSync() bool {
count := 1
count, threshold := 1, len(node.ConsensusNodes)*2/3+1
final := node.Graph.MyFinalNumber
for id, _ := range node.ConsensusNodes {
remote := node.SyncPoints.Get(id)
Expand All @@ -322,20 +322,21 @@ func (node *Node) CheckSync() bool {
count += 1
}
}
return count >= len(node.ConsensusNodes)*2/3+1
return count >= threshold
}

func (node *Node) CheckCatchUp() bool {
if node.SyncPoints.Len() != len(node.ConsensusNodes)-1 {
threshold := len(node.ConsensusNodes)*2/3 + 1
if node.SyncPoints.Len() < threshold {
return false
}
final := node.Graph.MyFinalNumber
cache := node.Graph.MyCacheRound
for id, _ := range node.ConsensusNodes {
if id == node.IdForNetwork {
remote := node.SyncPoints.Get(id)
if remote == nil {
continue
}
remote := node.SyncPoints.Get(id)
if remote.Number <= final {
continue
}
Expand Down

0 comments on commit b5ba9f0

Please sign in to comment.