• 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

14.63
/build/log.go
1
package build
2

3
import (
4
        "os"
5

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

9
// LogType is an indicating the type of logging specified by the build flag.
10
type LogType byte
11

12
const (
13
        // LogTypeNone indicates no logging.
14
        LogTypeNone LogType = iota
15

16
        // LogTypeStdOut all logging is written directly to stdout.
17
        LogTypeStdOut
18

19
        // LogTypeDefault logs to both stdout and a given io.PipeWriter.
20
        LogTypeDefault
21
)
22

23
// String returns a human readable identifier for the logging type.
24
func (t LogType) String() string {
×
25
        switch t {
×
26
        case LogTypeNone:
×
27
                return "none"
×
28
        case LogTypeStdOut:
×
29
                return "stdout"
×
30
        case LogTypeDefault:
×
31
                return "default"
×
32
        default:
×
33
                return "unknown"
×
34
        }
35
}
36

37
// Declare the supported log file compressors as exported consts for easier use
38
// from other projects.
39
const (
40
        // Gzip is the default compressor.
41
        Gzip = "gzip"
42

43
        // Zstd is a modern compressor that compresses better than Gzip, in less
44
        // time.
45
        Zstd = "zstd"
46
)
47

48
// logCompressors maps the identifier for each supported compression algorithm
49
// to the extension used for the compressed log files.
50
var logCompressors = map[string]string{
51
        Gzip: "gz",
52
        Zstd: "zst",
53
}
54

55
// SupportedLogCompressor returns whether or not logCompressor is a supported
56
// compression algorithm for log files.
UNCOV
57
func SupportedLogCompressor(logCompressor string) bool {
×
UNCOV
58
        _, ok := logCompressors[logCompressor]
×
UNCOV
59

×
UNCOV
60
        return ok
×
UNCOV
61
}
×
62

63
// NewSubLogger constructs a new subsystem log from the current LogWriter
64
// implementation. This is primarily intended for use with stdlog, as the actual
65
// writer is shared amongst all instantiations.
66
func NewSubLogger(subsystem string,
67
        genSubLogger func(string) btclog.Logger) btclog.Logger {
687✔
68

687✔
69
        switch Deployment {
687✔
70

71
        // For production builds, generate a new subsystem logger from the
72
        // primary log backend. If no function is provided, logging will be
73
        // disabled.
74
        case Production:
×
75
                if genSubLogger != nil {
×
76
                        return genSubLogger(subsystem)
×
77
                }
×
78

79
        // For development builds, we must handle two distinct types of logging:
80
        // unit tests and running the live daemon, e.g. for integration testing.
81
        case Development:
687✔
82
                switch LoggingType {
687✔
83

84
                // Default logging is used when running the standalone daemon.
85
                // We'll use the optional sublogger constructor to mimic the
86
                // production behavior.
UNCOV
87
                case LogTypeDefault:
×
UNCOV
88
                        if genSubLogger != nil {
×
UNCOV
89
                                return genSubLogger(subsystem)
×
UNCOV
90
                        }
×
91

92
                // Logging to stdout is used in unit tests. It is not important
93
                // that they share the same backend, since all output is written
94
                // to std out.
95
                case LogTypeStdOut:
×
96
                        backend := btclog.NewDefaultHandler(os.Stdout)
×
97
                        logger := btclog.NewSLogger(
×
98
                                backend.SubSystem(subsystem),
×
99
                        )
×
100

×
101
                        // Set the logging level of the stdout logger to use the
×
102
                        // configured logging level specified by build flags.
×
103
                        level, _ := btclog.LevelFromString(LogLevel)
×
104
                        logger.SetLevel(level)
×
105

×
106
                        return logger
×
107
                }
108
        }
109

110
        // For any other configurations, we'll disable logging.
111
        return btclog.Disabled
687✔
112
}
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