aboutsummaryrefslogtreecommitdiffstats
path: root/core/consensus.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-09-18 09:07:52 +0800
committerGitHub <noreply@github.com>2018-09-18 09:07:52 +0800
commit81cf96477127a2da8843d544802027c7061a9c06 (patch)
tree70c06aec5df92df1dd93b605cc7afdbd2b8b0347 /core/consensus.go
parent8a908e98279d7e80978cd412057eddd4a6bbf06c (diff)
downloadtangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.gz
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.bz2
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.lz
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.xz
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.tar.zst
tangerine-consensus-81cf96477127a2da8843d544802027c7061a9c06.zip
core: remove ticker parameter from NewConsensus
- remove BlockProposingInterval, it's replaced by lambda. - remove ticker parameter of NewConsensus, ticker would be derived from governance. - leave a backdoor to hook the construction of ticker. - move 'Lambda' config from to consensus.
Diffstat (limited to 'core/consensus.go')
-rw-r--r--core/consensus.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/core/consensus.go b/core/consensus.go
index 5e56ab9..6f59638 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -124,7 +124,7 @@ type Consensus struct {
ccModule *compactionChain
db blockdb.BlockDatabase
network Network
- tick *time.Ticker
+ tickerObj Ticker
prvKey crypto.PrivateKey
sigToPub SigToPubFn
lock sync.RWMutex
@@ -138,7 +138,6 @@ func NewConsensus(
gov Governance,
db blockdb.BlockDatabase,
network Network,
- tick *time.Ticker,
prv crypto.PrivateKey,
sigToPub SigToPubFn) *Consensus {
validatorSet := gov.GetValidatorSet()
@@ -172,7 +171,7 @@ func NewConsensus(
gov: gov,
db: db,
network: network,
- tick: tick,
+ tickerObj: newTicker(gov),
prvKey: prv,
sigToPub: sigToPub,
ctx: ctx,
@@ -202,7 +201,6 @@ func NewConsensus(
blockProposer,
)
}
-
return con
}
@@ -216,10 +214,10 @@ func (con *Consensus) Run() {
}
go con.processMsg(con.network.ReceiveChan(), con.PreProcessBlock)
// Reset ticker.
- <-con.tick.C
- <-con.tick.C
+ <-con.tickerObj.Tick()
+ <-con.tickerObj.Tick()
for {
- <-con.tick.C
+ <-con.tickerObj.Tick()
for _, tick := range ticks {
go func(tick chan struct{}) { tick <- struct{}{} }(tick)
}
@@ -302,7 +300,7 @@ func (con *Consensus) RunLegacy() {
ProposingBlockLoop:
for {
select {
- case <-con.tick.C:
+ case <-con.tickerObj.Tick():
case <-con.ctx.Done():
break ProposingBlockLoop
}