• 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

66.67
/channeldb/options.go
1
package channeldb
2

3
import (
4
        "github.com/lightningnetwork/lnd/clock"
5
)
6

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

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

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

25
// OptionalMiragtionConfig defines the flags used to signal whether a
26
// particular migration needs to be applied.
27
type OptionalMiragtionConfig struct {
28
        // PruneRevocationLog specifies that the revocation log migration needs
29
        // to be applied.
30
        PruneRevocationLog bool
31
}
32

33
// Options holds parameters for tuning and customizing a channeldb.DB.
34
type Options struct {
35
        OptionalMiragtionConfig
36

37
        // NoMigration specifies that underlying backend was opened in read-only
38
        // mode and migrations shouldn't be performed. This can be useful for
39
        // applications that use the channeldb package as a library.
40
        NoMigration bool
41

42
        // NoRevLogAmtData when set to true, indicates that amount data should
43
        // not be stored in the revocation log.
44
        NoRevLogAmtData bool
45

46
        // clock is the time source used by the database.
47
        clock clock.Clock
48

49
        // dryRun will fail to commit a successful migration when opening the
50
        // database if set to true.
51
        dryRun bool
52

53
        // keepFailedPaymentAttempts determines whether failed htlc attempts
54
        // are kept on disk or removed to save space.
55
        keepFailedPaymentAttempts bool
56

57
        // storeFinalHtlcResolutions determines whether to persistently store
58
        // the final resolution of incoming htlcs.
59
        storeFinalHtlcResolutions bool
60
}
61

62
// DefaultOptions returns an Options populated with default values.
63
func DefaultOptions() Options {
1,747✔
64
        return Options{
1,747✔
65
                OptionalMiragtionConfig: OptionalMiragtionConfig{},
1,747✔
66
                NoMigration:             false,
1,747✔
67
                clock:                   clock.NewDefaultClock(),
1,747✔
68
        }
1,747✔
69
}
1,747✔
70

71
// OptionModifier is a function signature for modifying the default Options.
72
type OptionModifier func(*Options)
73

74
// OptionNoRevLogAmtData sets the NoRevLogAmtData option to the given value. If
75
// it is set to true then amount data will not be stored in the revocation log.
UNCOV
76
func OptionNoRevLogAmtData(noAmtData bool) OptionModifier {
×
UNCOV
77
        return func(o *Options) {
×
UNCOV
78
                o.NoRevLogAmtData = noAmtData
×
UNCOV
79
        }
×
80
}
81

82
// OptionNoMigration allows the database to be opened in read only mode by
83
// disabling migrations.
84
func OptionNoMigration(b bool) OptionModifier {
×
85
        return func(o *Options) {
×
86
                o.NoMigration = b
×
87
        }
×
88
}
89

90
// OptionClock sets a non-default clock dependency.
91
func OptionClock(clock clock.Clock) OptionModifier {
154✔
92
        return func(o *Options) {
308✔
93
                o.clock = clock
154✔
94
        }
154✔
95
}
96

97
// OptionDryRunMigration controls whether or not to intentionally fail to commit a
98
// successful migration that occurs when opening the database.
99
func OptionDryRunMigration(dryRun bool) OptionModifier {
1✔
100
        return func(o *Options) {
2✔
101
                o.dryRun = dryRun
1✔
102
        }
1✔
103
}
104

105
// OptionKeepFailedPaymentAttempts controls whether failed payment attempts are
106
// kept on disk after a payment settles.
107
func OptionKeepFailedPaymentAttempts(keepFailedPaymentAttempts bool) OptionModifier {
9✔
108
        return func(o *Options) {
18✔
109
                o.keepFailedPaymentAttempts = keepFailedPaymentAttempts
9✔
110
        }
9✔
111
}
112

113
// OptionStoreFinalHtlcResolutions controls whether to persistently store the
114
// final resolution of incoming htlcs.
115
func OptionStoreFinalHtlcResolutions(
116
        storeFinalHtlcResolutions bool) OptionModifier {
7✔
117

7✔
118
        return func(o *Options) {
20✔
119
                o.storeFinalHtlcResolutions = storeFinalHtlcResolutions
13✔
120
        }
13✔
121
}
122

123
// OptionPruneRevocationLog specifies whether the migration for pruning
124
// revocation logs needs to be applied or not.
UNCOV
125
func OptionPruneRevocationLog(prune bool) OptionModifier {
×
UNCOV
126
        return func(o *Options) {
×
UNCOV
127
                o.OptionalMiragtionConfig.PruneRevocationLog = prune
×
UNCOV
128
        }
×
129
}
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