• 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

36.11
/build/config.go
1
package build
2

3
import (
4
        "fmt"
5

6
        "github.com/btcsuite/btclog/v2"
7
)
8

9
const (
10
        callSiteOff   = "off"
11
        callSiteShort = "short"
12
        callSiteLong  = "long"
13

14
        defaultLogCompressor = Gzip
15

16
        // DefaultMaxLogFiles is the default maximum number of log files to
17
        // keep.
18
        DefaultMaxLogFiles = 10
19

20
        // DefaultMaxLogFileSize is the default maximum log file size in MB.
21
        DefaultMaxLogFileSize = 20
22
)
23

24
// LogConfig holds logging configuration options.
25
//
26
//nolint:ll
27
type LogConfig struct {
28
        Console      *consoleLoggerCfg `group:"console" namespace:"console" description:"The logger writing to stdout and stderr."`
29
        File         *FileLoggerConfig `group:"file" namespace:"file" description:"The logger writing to LND's standard log file."`
30
        NoCommitHash bool              `long:"no-commit-hash" description:"If set, the commit-hash of the current build will not be included in log lines by default."`
31
}
32

33
// Validate validates the LogConfig struct values.
UNCOV
34
func (c *LogConfig) Validate() error {
×
UNCOV
35
        if !SupportedLogCompressor(c.File.Compressor) {
×
36
                return fmt.Errorf("invalid log compressor: %v",
×
37
                        c.File.Compressor)
×
38
        }
×
39

UNCOV
40
        return nil
×
41
}
42

43
// LoggerConfig holds options for a particular logger.
44
//
45
//nolint:ll
46
type LoggerConfig struct {
47
        Disable      bool   `long:"disable" description:"Disable this logger."`
48
        NoTimestamps bool   `long:"no-timestamps" description:"Omit timestamps from log lines."`
49
        CallSite     string `long:"call-site" description:"Include the call-site of each log line." choice:"off" choice:"short" choice:"long"`
50
}
51

52
// DefaultLogConfig returns the default logging config options.
53
func DefaultLogConfig() *LogConfig {
1✔
54
        return &LogConfig{
1✔
55
                Console: defaultConsoleLoggerCfg(),
1✔
56
                File: &FileLoggerConfig{
1✔
57
                        Compressor:     defaultLogCompressor,
1✔
58
                        MaxLogFiles:    DefaultMaxLogFiles,
1✔
59
                        MaxLogFileSize: DefaultMaxLogFileSize,
1✔
60
                        LoggerConfig: LoggerConfig{
1✔
61
                                CallSite: callSiteOff,
1✔
62
                        },
1✔
63
                },
1✔
64
        }
1✔
65
}
1✔
66

67
// HandlerOptions returns the set of btclog.HandlerOptions that the state of the
68
// config struct translates to.
UNCOV
69
func (cfg *LoggerConfig) HandlerOptions() []btclog.HandlerOption {
×
UNCOV
70
        opts := []btclog.HandlerOption{
×
UNCOV
71
                // We wrap the logger provided by the logging library with
×
UNCOV
72
                // another layer of abstraction with the handlerSet, and so we
×
UNCOV
73
                // need to increase the default skip depth by 1.
×
UNCOV
74
                btclog.WithCallSiteSkipDepth(btclog.DefaultSkipDepth + 1),
×
UNCOV
75
        }
×
UNCOV
76

×
UNCOV
77
        if cfg.NoTimestamps {
×
78
                opts = append(opts, btclog.WithNoTimestamp())
×
79
        }
×
80

UNCOV
81
        switch cfg.CallSite {
×
UNCOV
82
        case callSiteShort:
×
UNCOV
83
                opts = append(opts, btclog.WithCallerFlags(btclog.Lshortfile))
×
84
        case callSiteLong:
×
85
                opts = append(opts, btclog.WithCallerFlags(btclog.Llongfile))
×
86
        }
87

UNCOV
88
        return opts
×
89
}
90

91
// FileLoggerConfig extends LoggerConfig with specific log file options.
92
//
93
//nolint:ll
94
type FileLoggerConfig struct {
95
        LoggerConfig
96
        Compressor     string `long:"compressor" description:"Compression algorithm to use when rotating logs." choice:"gzip" choice:"zstd"`
97
        MaxLogFiles    int    `long:"max-files" description:"Maximum logfiles to keep (0 for no rotation)"`
98
        MaxLogFileSize int    `long:"max-file-size" description:"Maximum logfile size in MB"`
99
}
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