Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
laizy committed Jul 19, 2024
1 parent fad6d2e commit 7c559a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
11 changes: 4 additions & 7 deletions consensus/vbft/event_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (self *EventTimer) CancelTxBlockTimeout(blockNum uint32) {
self.cancelEventTimer(EventTxBlockTimeout, blockNum)
}

func (self *EventTimer) startPeerTicker(peerIdx uint32) error {
func (self *EventTimer) startPeerTicker(peerIdx uint32) {
self.lock.Lock()
defer self.lock.Unlock()

Expand All @@ -319,29 +319,26 @@ func (self *EventTimer) startPeerTicker(peerIdx uint32) error {
}
self.peerTickers[peerIdx].Reset(timeout)
})

return nil
}

func (self *EventTimer) stopPeerTicker(peerIdx uint32) error {
func (self *EventTimer) stopPeerTicker(peerIdx uint32) {
self.lock.Lock()
defer self.lock.Unlock()

if p, present := self.peerTickers[peerIdx]; present {
p.Stop()
delete(self.peerTickers, peerIdx)
}
return nil
}

func (self *EventTimer) startTxTicker(blockNum uint32) {
func (self *EventTimer) startTxPoolTicker(blockNum uint32) {
self.lock.Lock()
defer self.lock.Unlock()

self.startEventTimer(EventTxPool, blockNum)
}

func (self *EventTimer) stopTxTicker(blockNum uint32) {
func (self *EventTimer) stopTxPoolTicker(blockNum uint32) {
self.lock.Lock()
defer self.lock.Unlock()

Expand Down
10 changes: 5 additions & 5 deletions consensus/vbft/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ func (self *Server) startNewRound() error {
self.processProposalMsg(proposal)
return nil
}
self.timer.startTxTicker(blkNum)
self.timer.startTxPoolTicker(blkNum)
self.timer.StartTxBlockTimeout(blkNum)
return nil
}
Expand Down Expand Up @@ -1835,7 +1835,7 @@ func (self *Server) processTimerEvent(evt *TimerEvent) error {
self.heartbeat()

case EventTxPool:
self.timer.stopTxTicker(evt.blockNum)
self.timer.stopTxPoolTicker(evt.blockNum)
if self.GetCompletedBlockNum()+1 == evt.blockNum {
validHeight := self.validHeight(evt.blockNum)
newProposal := false
Expand All @@ -1851,13 +1851,13 @@ func (self *Server) processTimerEvent(evt *TimerEvent) error {
self.startNewProposal(evt.blockNum)
} else {
//reset timer, continue waiting txs from txnpool
self.timer.startTxTicker(evt.blockNum)
self.timer.startTxPoolTicker(evt.blockNum)
}
} else {
self.timer.startTxTicker(evt.blockNum)
self.timer.startTxPoolTicker(evt.blockNum)
}
case EventTxBlockTimeout:
self.timer.stopTxTicker(evt.blockNum)
self.timer.stopTxPoolTicker(evt.blockNum)
self.timer.CancelTxBlockTimeout(evt.blockNum)
self.startNewProposal(evt.blockNum)
}
Expand Down

0 comments on commit 7c559a9

Please sign in to comment.