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

lightningnetwork / lnd / 12284350326

11 Dec 2024 08:27PM UTC coverage: 57.485% (+7.9%) from 49.54%
12284350326

Pull #9348

github

ziggie1984
github: update goveralls tool
Pull Request #9348: github: update goveralls tool

101901 of 177264 relevant lines covered (57.49%)

24841.21 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,737✔
64
        return Options{
1,737✔
65
                OptionalMiragtionConfig: OptionalMiragtionConfig{},
1,737✔
66
                NoMigration:             false,
1,737✔
67
                clock:                   clock.NewDefaultClock(),
1,737✔
68
        }
1,737✔
69
}
1,737✔
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.
76
func OptionNoRevLogAmtData(noAmtData bool) OptionModifier {
×
77
        return func(o *Options) {
×
78
                o.NoRevLogAmtData = noAmtData
×
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 {
151✔
92
        return func(o *Options) {
302✔
93
                o.clock = clock
151✔
94
        }
151✔
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.
125
func OptionPruneRevocationLog(prune bool) OptionModifier {
×
126
        return func(o *Options) {
×
127
                o.OptionalMiragtionConfig.PruneRevocationLog = prune
×
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