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

lightningnetwork / lnd / 15736109134

18 Jun 2025 02:46PM UTC coverage: 58.197% (-10.1%) from 68.248%
15736109134

Pull #9752

github

web-flow
Merge d2634a68c into 31c74f20f
Pull Request #9752: routerrpc: reject payment to invoice that don't have payment secret or blinded paths

6 of 13 new or added lines in 2 files covered. (46.15%)

28331 existing lines in 455 files now uncovered.

97860 of 168153 relevant lines covered (58.2%)

1.81 hits per line

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

87.5
/graph/db/channel_cache.go
1
package graphdb
2

3
// channelCache is an in-memory cache used to improve the performance of
4
// ChanUpdatesInHorizon. It caches the chan info and edge policies for a
5
// particular channel.
6
type channelCache struct {
7
        n        int
8
        channels map[uint64]ChannelEdge
9
}
10

11
// newChannelCache creates a new channelCache with maximum capacity of n
12
// channels.
13
func newChannelCache(n int) *channelCache {
3✔
14
        return &channelCache{
3✔
15
                n:        n,
3✔
16
                channels: make(map[uint64]ChannelEdge),
3✔
17
        }
3✔
18
}
3✔
19

20
// get returns the channel from the cache, if it exists.
21
func (c *channelCache) get(chanid uint64) (ChannelEdge, bool) {
3✔
22
        channel, ok := c.channels[chanid]
3✔
23
        return channel, ok
3✔
24
}
3✔
25

26
// insert adds the entry to the channel cache. If an entry for chanid already
27
// exists, it will be replaced with the new entry. If the entry doesn't exist,
28
// it will be inserted to the cache, performing a random eviction if the cache
29
// is at capacity.
30
func (c *channelCache) insert(chanid uint64, channel ChannelEdge) {
3✔
31
        // If entry exists, replace it.
3✔
32
        if _, ok := c.channels[chanid]; ok {
6✔
33
                c.channels[chanid] = channel
3✔
34
                return
3✔
35
        }
3✔
36

37
        // Otherwise, evict an entry at random and insert.
38
        if len(c.channels) == c.n {
3✔
UNCOV
39
                for id := range c.channels {
×
UNCOV
40
                        delete(c.channels, id)
×
UNCOV
41
                        break
×
42
                }
43
        }
44
        c.channels[chanid] = channel
3✔
45
}
46

47
// remove deletes an edge for chanid from the cache, if it exists.
48
func (c *channelCache) remove(chanid uint64) {
3✔
49
        delete(c.channels, chanid)
3✔
50
}
3✔
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