diff options
author | BJ4 <bojie@dexon.org> | 2018-11-02 18:09:57 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:17 +0800 |
commit | 5bd42d357da00298fa47bd8c672721195cf61d9a (patch) | |
tree | de53593d22ea0cb9d4391b4284024560bf7f4497 /vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go | |
parent | 00f2c4e5a65533dd3e2cd726ee55f90c477ad6c3 (diff) | |
download | go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.gz go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.bz2 go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.lz go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.xz go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.tar.zst go-tangerine-5bd42d357da00298fa47bd8c672721195cf61d9a.zip |
app: lock by chain correctly and remove old core in vendor
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go index 2be596abc..08006dbfb 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go @@ -59,13 +59,8 @@ type leaderSelector struct { lock sync.Mutex } -func newLeaderSelector( - crs common.Hash, validLeader validLeaderFn) *leaderSelector { - numCRS := big.NewInt(0) - numCRS.SetBytes(crs[:]) +func newLeaderSelector(validLeader validLeaderFn) *leaderSelector { return &leaderSelector{ - numCRS: numCRS, - hashCRS: crs, minCRSBlock: maxHash, validLeader: validLeader, } @@ -86,9 +81,13 @@ func (l *leaderSelector) probability(sig crypto.Signature) float64 { return p } -func (l *leaderSelector) restart() { +func (l *leaderSelector) restart(crs common.Hash) { + numCRS := big.NewInt(0) + numCRS.SetBytes(crs[:]) l.lock.Lock() defer l.lock.Unlock() + l.numCRS = numCRS + l.hashCRS = crs l.minCRSBlock = maxHash l.minBlockHash = common.Hash{} l.pendingBlocks = []*types.Block{} |