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

lightningnetwork / lnd / 13725358077

07 Mar 2025 04:51PM UTC coverage: 58.224% (-10.4%) from 68.615%
13725358077

Pull #9458

github

web-flow
Merge bf4c6625f into ab2dc09eb
Pull Request #9458: multi+server.go: add initial permissions for some peers

346 of 549 new or added lines in 10 files covered. (63.02%)

27466 existing lines in 443 files now uncovered.

94609 of 162492 relevant lines covered (58.22%)

1.81 hits per line

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

77.78
/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 {
3✔
64
        return Options{
3✔
65
                OptionalMiragtionConfig: OptionalMiragtionConfig{},
3✔
66
                NoMigration:             false,
3✔
67
                clock:                   clock.NewDefaultClock(),
3✔
68
        }
3✔
69
}
3✔
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 {
3✔
77
        return func(o *Options) {
6✔
78
                o.NoRevLogAmtData = noAmtData
3✔
79
        }
3✔
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.
UNCOV
91
func OptionClock(clock clock.Clock) OptionModifier {
×
UNCOV
92
        return func(o *Options) {
×
UNCOV
93
                o.clock = clock
×
UNCOV
94
        }
×
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 {
3✔
100
        return func(o *Options) {
6✔
101
                o.dryRun = dryRun
3✔
102
        }
3✔
103
}
104

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

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

3✔
118
        return func(o *Options) {
6✔
119
                o.storeFinalHtlcResolutions = storeFinalHtlcResolutions
3✔
120
        }
3✔
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 {
3✔
126
        return func(o *Options) {
6✔
127
                o.OptionalMiragtionConfig.PruneRevocationLog = prune
3✔
128
        }
3✔
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