aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/utils
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/utils')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/utils/nodeset-cache.go38
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/utils/round-event.go2
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/utils/utils.go5
3 files changed, 12 insertions, 33 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/nodeset-cache.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/nodeset-cache.go
index 89ebd2409..89dcfc86b 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/nodeset-cache.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/nodeset-cache.go
@@ -36,10 +36,9 @@ var (
)
type sets struct {
- crs common.Hash
- nodeSet *types.NodeSet
- notarySet map[types.NodeID]struct{}
- leaderNode map[uint64]types.NodeID
+ crs common.Hash
+ nodeSet *types.NodeSet
+ notarySet map[types.NodeID]struct{}
}
// NodeSetCacheInterface interface specifies interface used by NodeSetCache.
@@ -133,30 +132,6 @@ func (cache *NodeSetCache) GetNotarySet(
return cache.cloneMap(IDs.notarySet), nil
}
-// GetLeaderNode returns the BA leader of the position.
-func (cache *NodeSetCache) GetLeaderNode(pos types.Position) (
- types.NodeID, error) {
- IDs, err := cache.getOrUpdate(pos.Round)
- if err != nil {
- return types.NodeID{}, err
- }
- cache.lock.Lock()
- defer cache.lock.Unlock()
- if _, exist := IDs.leaderNode[pos.Height]; !exist {
- notarySet := types.NewNodeSetFromMap(IDs.notarySet)
- leader := notarySet.GetSubSet(1, types.NewNodeLeaderTarget(
- IDs.crs, pos.Height))
- if len(leader) != 1 {
- panic(errors.New("length of leader is not one"))
- }
- for nID := range leader {
- IDs.leaderNode[pos.Height] = nID
- break
- }
- }
- return IDs.leaderNode[pos.Height], nil
-}
-
// Purge a specific round.
func (cache *NodeSetCache) Purge(rID uint64) {
cache.lock.Lock()
@@ -238,10 +213,9 @@ func (cache *NodeSetCache) update(round uint64) (nIDs *sets, err error) {
return
}
nIDs = &sets{
- crs: crs,
- nodeSet: nodeSet,
- notarySet: make(map[types.NodeID]struct{}),
- leaderNode: make(map[uint64]types.NodeID, cfg.RoundLength),
+ crs: crs,
+ nodeSet: nodeSet,
+ notarySet: make(map[types.NodeID]struct{}),
}
nIDs.notarySet = nodeSet.GetSubSet(
int(cfg.NotarySetSize), types.NewNotarySetTarget(crs))
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/round-event.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/round-event.go
index 472c7247b..602d2da16 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/round-event.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/round-event.go
@@ -79,7 +79,7 @@ func (e RoundEventParam) NextRoundHeight() uint64 {
// NextTouchNodeSetCacheHeight returns the height to touch the node set cache.
func (e RoundEventParam) NextTouchNodeSetCacheHeight() uint64 {
- return e.BeginHeight + e.Config.RoundLength*9/10
+ return e.BeginHeight + e.Config.RoundLength/2
}
// NextDKGResetHeight returns the height to reset DKG for next period.
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/utils.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/utils.go
index e6739ce2b..1a372c70c 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/utils.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/utils.go
@@ -144,6 +144,11 @@ func GetDKGValidThreshold(config *types.Config) int {
return int(config.NotarySetSize * 5 / 6)
}
+// GetBAThreshold return threshold for BA votes.
+func GetBAThreshold(config *types.Config) int {
+ return int(config.NotarySetSize*2/3 + 1)
+}
+
// GetNextRoundValidationHeight returns the block height to check if the next
// round is ready.
func GetNextRoundValidationHeight(begin, length uint64) uint64 {