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

lightningnetwork / lnd / 13536249039

26 Feb 2025 03:42AM UTC coverage: 57.462% (-1.4%) from 58.835%
13536249039

Pull #8453

github

Roasbeef
peer: update chooseDeliveryScript to gen script if needed

In this commit, we update `chooseDeliveryScript` to generate a new
script if needed. This allows us to fold in a few other lines that
always followed this function into this expanded function.

The tests have been updated accordingly.
Pull Request #8453: [4/4] - multi: integrate new rbf coop close FSM into the existing peer flow

275 of 1318 new or added lines in 22 files covered. (20.86%)

19521 existing lines in 257 files now uncovered.

103858 of 180741 relevant lines covered (57.46%)

24750.23 hits per line

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

44.83
/graph/db/options.go
1
package graphdb
2

3
import "time"
4

5
const (
6
        // DefaultRejectCacheSize is the default number of rejectCacheEntries to
7
        // cache for use in the rejection cache of incoming gossip traffic. This
8
        // produces a cache size of around 1MB.
9
        DefaultRejectCacheSize = 50000
10

11
        // DefaultChannelCacheSize is the default number of ChannelEdges cached
12
        // in order to reply to gossip queries. This produces a cache size of
13
        // around 40MB.
14
        DefaultChannelCacheSize = 20000
15

16
        // DefaultPreAllocCacheNumNodes is the default number of channels we
17
        // assume for mainnet for pre-allocating the graph cache. As of
18
        // September 2021, there currently are 14k nodes in a strictly pruned
19
        // graph, so we choose a number that is slightly higher.
20
        DefaultPreAllocCacheNumNodes = 15000
21
)
22

23
// Options holds parameters for tuning and customizing a graph.DB.
24
type Options struct {
25
        // RejectCacheSize is the maximum number of rejectCacheEntries to hold
26
        // in the rejection cache.
27
        RejectCacheSize int
28

29
        // ChannelCacheSize is the maximum number of ChannelEdges to hold in the
30
        // channel cache.
31
        ChannelCacheSize int
32

33
        // BatchCommitInterval is the maximum duration the batch schedulers will
34
        // wait before attempting to commit a pending set of updates.
35
        BatchCommitInterval time.Duration
36

37
        // PreAllocCacheNumNodes is the number of nodes we expect to be in the
38
        // graph cache, so we can pre-allocate the map accordingly.
39
        PreAllocCacheNumNodes int
40

41
        // UseGraphCache denotes whether the in-memory graph cache should be
42
        // used or a fallback version that uses the underlying database for
43
        // path finding.
44
        UseGraphCache bool
45

46
        // NoMigration specifies that underlying backend was opened in read-only
47
        // mode and migrations shouldn't be performed. This can be useful for
48
        // applications that use the channeldb package as a library.
49
        NoMigration bool
50
}
51

52
// DefaultOptions returns an Options populated with default values.
53
func DefaultOptions() *Options {
213✔
54
        return &Options{
213✔
55
                RejectCacheSize:       DefaultRejectCacheSize,
213✔
56
                ChannelCacheSize:      DefaultChannelCacheSize,
213✔
57
                PreAllocCacheNumNodes: DefaultPreAllocCacheNumNodes,
213✔
58
                UseGraphCache:         true,
213✔
59
                NoMigration:           false,
213✔
60
        }
213✔
61
}
213✔
62

63
// OptionModifier is a function signature for modifying the default Options.
64
type OptionModifier func(*Options)
65

66
// WithRejectCacheSize sets the RejectCacheSize to n.
UNCOV
67
func WithRejectCacheSize(n int) OptionModifier {
×
UNCOV
68
        return func(o *Options) {
×
UNCOV
69
                o.RejectCacheSize = n
×
UNCOV
70
        }
×
71
}
72

73
// WithChannelCacheSize sets the ChannelCacheSize to n.
UNCOV
74
func WithChannelCacheSize(n int) OptionModifier {
×
UNCOV
75
        return func(o *Options) {
×
UNCOV
76
                o.ChannelCacheSize = n
×
UNCOV
77
        }
×
78
}
79

80
// WithPreAllocCacheNumNodes sets the PreAllocCacheNumNodes to n.
81
func WithPreAllocCacheNumNodes(n int) OptionModifier {
×
82
        return func(o *Options) {
×
83
                o.PreAllocCacheNumNodes = n
×
84
        }
×
85
}
86

87
// WithBatchCommitInterval sets the batch commit interval for the interval batch
88
// schedulers.
UNCOV
89
func WithBatchCommitInterval(interval time.Duration) OptionModifier {
×
UNCOV
90
        return func(o *Options) {
×
UNCOV
91
                o.BatchCommitInterval = interval
×
UNCOV
92
        }
×
93
}
94

95
// WithUseGraphCache sets the UseGraphCache option to the given value.
96
func WithUseGraphCache(use bool) OptionModifier {
102✔
97
        return func(o *Options) {
204✔
98
                o.UseGraphCache = use
102✔
99
        }
102✔
100
}
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