diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-09-23 20:51:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-23 20:51:05 +0800 |
commit | 0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89 (patch) | |
tree | 626db6969aee92702001e5c9f3de56e2a439ccac /core/ticker.go | |
parent | 2c71e8448a9c03e924a7869351eebf2def1af057 (diff) | |
download | dexon-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.tar dexon-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.tar.gz dexon-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.tar.bz2 dexon-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.tar.lz dexon-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.tar.xz dexon-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.tar.zst dexon-consensus-0ab5a2d4f63ece79a4df32c6fb3ac710a954fd89.zip |
core: run first DKG at startup. (#129)
Diffstat (limited to 'core/ticker.go')
-rw-r--r-- | core/ticker.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/core/ticker.go b/core/ticker.go index bb5afb4..5dbbc2a 100644 --- a/core/ticker.go +++ b/core/ticker.go @@ -19,6 +19,15 @@ package core import "time" +// TickerType is the type of ticker. +type TickerType int + +// TickerType enum. +const ( + TickerBA TickerType = iota + TickerDKG +) + // defaultTicker is a wrapper to implement ticker interface based on // time.Ticker. type defaultTicker struct { @@ -43,16 +52,23 @@ func (t *defaultTicker) Stop() { // newTicker is a helper to setup a ticker by giving an Governance. If // the governace object implements a ticker generator, a ticker from that // generator would be returned, else constructs a default one. -func newTicker(gov Governance) (t Ticker) { +func newTicker(gov Governance, tickerType TickerType) (t Ticker) { type tickerGenerator interface { - NewTicker() Ticker + NewTicker(TickerType) Ticker } if gen, ok := gov.(tickerGenerator); ok { - t = gen.NewTicker() + t = gen.NewTicker(tickerType) } if t == nil { - t = newDefaultTicker(gov.GetConfiguration(0).Lambda) + var duration time.Duration + switch tickerType { + case TickerBA: + duration = gov.GetConfiguration(0).LambdaBA + case TickerDKG: + duration = gov.GetConfiguration(0).LambdaDKG + } + t = newDefaultTicker(duration) } return } |