MCPcopy Create free account
hub / github.com/DNAProject/DNA / StartTimer

Method StartTimer

consensus/vbft/event_timer.go:125–145  ·  view source on GitHub ↗
(Idx uint32, timeout time.Duration)

Source from the content-addressed store, hash-verified

123}
124
125func (self *EventTimer) StartTimer(Idx uint32, timeout time.Duration) {
126 self.lock.Lock()
127 defer self.lock.Unlock()
128
129 if t, present := self.normalTimers[Idx]; present {
130 t.Stop()
131 log.Infof("timer for %d got reset", Idx)
132 }
133
134 self.normalTimers[Idx] = time.AfterFunc(timeout, func() {
135 // remove timer from map
136 self.lock.Lock()
137 defer self.lock.Unlock()
138 delete(self.normalTimers, Idx)
139
140 self.C <- &TimerEvent{
141 evtType: EventMax,
142 blockNum: Idx,
143 }
144 })
145}
146
147func (self *EventTimer) CancelTimer(idx uint32) {
148 self.lock.Lock()

Callers 2

TestStartTimerFunction · 0.80
TestCancelTimerFunction · 0.80

Calls 2

InfofFunction · 0.92
StopMethod · 0.65

Tested by 2

TestStartTimerFunction · 0.64
TestCancelTimerFunction · 0.64