Files
zeekayandHanzo Dev b1cc108c9f gofmt
Co-authored-by: Hanzo Dev <[email protected]>
2026-09-08 01:51:51 -07:00

41 lines
759 B
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package txheap
import (
"time"
"github.com/luxfi/container/heap"
"github.com/luxfi/ids"
"github.com/luxfi/node/vms/platformvm/txs"
)
var _ TimedHeap = (*byEndTime)(nil)
type TimedHeap interface {
Heap
Timestamp() time.Time
}
type byEndTime struct {
txHeap
}
func NewByEndTime() TimedHeap {
return &byEndTime{
txHeap: txHeap{
heap: heap.NewMap[ids.ID, *txs.Tx](func(a, b *txs.Tx) bool {
aTime := a.Unsigned.(txs.Staker).EndTime()
bTime := b.Unsigned.(txs.Staker).EndTime()
return aTime.Before(bTime)
}),
},
}
}
func (h *byEndTime) Timestamp() time.Time {
return h.Peek().Unsigned.(txs.Staker).EndTime()
}