Skip to content

Commit

Permalink
clean unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
laizy committed Jul 19, 2024
1 parent 7596e5f commit fad6d2e
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions consensus/vbft/event_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package vbft

import (
"container/heap"
"math/rand"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -348,51 +347,3 @@ func (self *EventTimer) stopTxTicker(blockNum uint32) {

self.cancelEventTimer(EventTxPool, blockNum)
}

///////////////////////////////////////////////////////////
//
// timer queue
//
///////////////////////////////////////////////////////////

type TimerItem struct {
due time.Time
evt *TimerEvent
index int
}

type TimerQueue []*TimerItem

func (tq TimerQueue) Len() int {
return len(tq)
}

func (tq TimerQueue) Less(i, j int) bool {
return tq[j].due.After(tq[i].due)
}

func (tq TimerQueue) Swap(i, j int) {
tq[i], tq[j] = tq[j], tq[i]
tq[i].index = i
tq[j].index = j
}

func (tq *TimerQueue) Push(x interface{}) {
item := x.(*TimerItem)
item.index = len(*tq)
*tq = append(*tq, item)
}

func (tq *TimerQueue) Pop() interface{} {
old := *tq
n := len(old)
item := old[n-1]
item.index = -1
*tq = old[0 : n-1]
return item
}

func (tq *TimerQueue) update(item *TimerItem, due time.Time) {
item.due = due
heap.Fix(tq, item.index)
}

0 comments on commit fad6d2e

Please sign in to comment.