Skip to content

Commit 200d412

Browse files
committed
mempool queue update generic constraints
1 parent 6bfdd53 commit 200d412

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

internal/list/list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func (e *Element[T]) GetExpiry() int64 {
6767
return e.value.GetExpiry()
6868
}
6969

70+
func (e *Element[T]) Priority() uint64 {
71+
return e.value.Priority()
72+
}
73+
7074
func (l *List[T]) First() *Element[T] {
7175
if l.size == 0 {
7276
return nil

internal/mempool/mempool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type Item interface {
3131
Priority() uint64
3232
}
3333

34-
type Mempool[T Item, E eheap.Item] struct {
34+
type Mempool[T Item, E queue.Item] struct {
3535
tracer trace.Tracer
3636

3737
mu sync.RWMutex

internal/mempool/queue/fifo_queue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/ava-labs/hypersdk/internal/list"
88
)
99

10-
var _ Queue[list.Item, *list.Element[list.Item]] = (*FIFOQueue[list.Item])(nil)
10+
var _ Queue[Item, *list.Element[Item]] = (*FIFOQueue[Item])(nil)
1111

1212
type FIFOQueue[T list.Item] struct {
1313
*list.List[T]

internal/mempool/queue/priority_queue.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
package queue
55

66
import (
7-
"github.com/ava-labs/hypersdk/internal/list"
87
"github.com/ava-labs/hypersdk/internal/pheap"
98
)
109

11-
var _ Queue[list.Item, list.Item] = (*PriorityQueue[list.Item])(nil)
10+
var _ Queue[Item, Item] = (*PriorityQueue[Item])(nil)
1211

13-
type PriorityQueue[T list.Item] struct {
12+
type PriorityQueue[T Item] struct {
1413
*pheap.PriorityHeap[T]
1514
}
1615

internal/mempool/queue/queue.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ type Item interface {
1313
Priority() uint64
1414
}
1515

16-
type Queue[T Item, Elem any] interface {
16+
type Queue[T Item, E Item] interface {
1717
Size() int
18-
First() (Elem, bool)
18+
First() (E, bool)
1919
FirstValue() (T, bool)
20-
Remove(Elem) T
21-
Push(T) Elem
22-
Restore(T) Elem
20+
Remove(E) T
21+
Push(T) E
22+
Restore(T) E
2323
}

0 commit comments

Comments
 (0)