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

lightningnetwork / lnd / 12343072627

15 Dec 2024 11:09PM UTC coverage: 57.504% (-1.1%) from 58.636%
12343072627

Pull #9315

github

yyforyongyu
contractcourt: offer outgoing htlc one block earlier before its expiry

We need to offer the outgoing htlc one block earlier to make sure when
the expiry height hits, the sweeper will not miss sweeping it in the
same block. This also means the outgoing contest resolver now only does
one thing - watch for preimage spend till height expiry-1, which can
easily be moved into the timeout resolver instead in the future.
Pull Request #9315: Implement `blockbeat`

1445 of 2007 new or added lines in 26 files covered. (72.0%)

19246 existing lines in 249 files now uncovered.

102342 of 177975 relevant lines covered (57.5%)

24772.24 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 {
212✔
54
        return &Options{
212✔
55
                RejectCacheSize:       DefaultRejectCacheSize,
212✔
56
                ChannelCacheSize:      DefaultChannelCacheSize,
212✔
57
                PreAllocCacheNumNodes: DefaultPreAllocCacheNumNodes,
212✔
58
                UseGraphCache:         true,
212✔
59
                NoMigration:           false,
212✔
60
        }
212✔
61
}
212✔
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 {
103✔
97
        return func(o *Options) {
206✔
98
                o.UseGraphCache = use
103✔
99
        }
103✔
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