• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 15561477203

10 Jun 2025 01:54PM UTC coverage: 58.351% (-10.1%) from 68.487%
15561477203

Pull #9356

github

web-flow
Merge 6440b25db into c6d6d4c0b
Pull Request #9356: lnrpc: add incoming/outgoing channel ids filter to forwarding history request

33 of 36 new or added lines in 2 files covered. (91.67%)

28366 existing lines in 455 files now uncovered.

97715 of 167461 relevant lines covered (58.35%)

1.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.7
/watchtower/wtclient/sess_close_min_heap.go
1
package wtclient
2

3
import (
4
        "sync"
5

6
        "github.com/lightningnetwork/lnd/queue"
7
        "github.com/lightningnetwork/lnd/watchtower/wtdb"
8
)
9

10
// sessionCloseMinHeap is a thread-safe min-heap implementation that stores
11
// sessionCloseItem items and prioritises the item with the lowest block height.
12
type sessionCloseMinHeap struct {
13
        queue queue.PriorityQueue
14
        mu    sync.Mutex
15
}
16

17
// newSessionCloseMinHeap constructs a new sessionCloseMineHeap.
18
func newSessionCloseMinHeap() *sessionCloseMinHeap {
3✔
19
        return &sessionCloseMinHeap{}
3✔
20
}
3✔
21

22
// Len returns the length of the queue.
UNCOV
23
func (h *sessionCloseMinHeap) Len() int {
×
UNCOV
24
        h.mu.Lock()
×
UNCOV
25
        defer h.mu.Unlock()
×
UNCOV
26

×
UNCOV
27
        return h.queue.Len()
×
UNCOV
28
}
×
29

30
// Empty returns true if the queue is empty.
UNCOV
31
func (h *sessionCloseMinHeap) Empty() bool {
×
UNCOV
32
        h.mu.Lock()
×
UNCOV
33
        defer h.mu.Unlock()
×
UNCOV
34

×
UNCOV
35
        return h.queue.Empty()
×
UNCOV
36
}
×
37

38
// Push adds an item to the priority queue.
39
func (h *sessionCloseMinHeap) Push(item *sessionCloseItem) {
3✔
40
        h.mu.Lock()
3✔
41
        defer h.mu.Unlock()
3✔
42

3✔
43
        h.queue.Push(item)
3✔
44
}
3✔
45

46
// Pop removes the top most item from the queue.
47
func (h *sessionCloseMinHeap) Pop() *sessionCloseItem {
3✔
48
        h.mu.Lock()
3✔
49
        defer h.mu.Unlock()
3✔
50

3✔
51
        if h.queue.Empty() {
3✔
UNCOV
52
                return nil
×
UNCOV
53
        }
×
54

55
        item := h.queue.Pop()
3✔
56

3✔
57
        return item.(*sessionCloseItem) //nolint:forcetypeassert
3✔
58
}
59

60
// Top returns the top most item from the queue without removing it.
61
func (h *sessionCloseMinHeap) Top() *sessionCloseItem {
3✔
62
        h.mu.Lock()
3✔
63
        defer h.mu.Unlock()
3✔
64

3✔
65
        if h.queue.Empty() {
6✔
66
                return nil
3✔
67
        }
3✔
68

69
        item := h.queue.Top()
3✔
70

3✔
71
        return item.(*sessionCloseItem) //nolint:forcetypeassert
3✔
72
}
73

74
// sessionCloseItem represents a session that is ready to be deleted.
75
type sessionCloseItem struct {
76
        // sessionID is the ID of the session in question.
77
        sessionID wtdb.SessionID
78

79
        // deleteHeight is the block height after which we can delete the
80
        // session.
81
        deleteHeight uint32
82
}
83

84
// Less returns true if the current item's delete height is less than the
85
// other sessionCloseItem's delete height. This results in lower block heights
86
// being popped first from the heap.
87
//
88
// NOTE: this is part of the queue.PriorityQueueItem interface.
UNCOV
89
func (s *sessionCloseItem) Less(other queue.PriorityQueueItem) bool {
×
UNCOV
90
        o := other.(*sessionCloseItem).deleteHeight //nolint:forcetypeassert
×
UNCOV
91

×
UNCOV
92
        return s.deleteHeight < o
×
UNCOV
93
}
×
94

95
var _ queue.PriorityQueueItem = (*sessionCloseItem)(nil)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc