• 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

13.21
/build/config_dev.go
1
//go:build dev
2
// +build dev
3

4
package build
5

6
import (
7
        "fmt"
8
        "strings"
9

10
        btclogv1 "github.com/btcsuite/btclog"
11
        "github.com/btcsuite/btclog/v2"
12
)
13

14
const (
15
        resetSeq = "0"
16
        boldSeq  = "1"
17
        faintSeq = "2"
18
        esc      = '\x1b'
19
        csi      = string(esc) + "["
20
)
21

22
// consoleLoggerCfg extends the LoggerConfig struct by adding a Color option
23
// which is only available for a console logger.
24
//
25
//nolint:ll
26
type consoleLoggerCfg struct {
27
        LoggerConfig
28
        Style bool `long:"style" description:"If set, the output will be styled with color and fonts"`
29
}
30

31
// defaultConsoleLoggerCfg returns the default consoleLoggerCfg for the dev
32
// console logger.
33
func defaultConsoleLoggerCfg() *consoleLoggerCfg {
1✔
34
        return &consoleLoggerCfg{
1✔
35
                LoggerConfig: LoggerConfig{
1✔
36
                        CallSite: callSiteShort,
1✔
37
                },
1✔
38
        }
1✔
39
}
1✔
40

41
// HandlerOptions returns the set of btclog.HandlerOptions that the state of the
42
// config struct translates to.
UNCOV
43
func (cfg *consoleLoggerCfg) HandlerOptions() []btclog.HandlerOption {
×
UNCOV
44
        opts := cfg.LoggerConfig.HandlerOptions()
×
UNCOV
45

×
UNCOV
46
        if !cfg.Style {
×
UNCOV
47
                return opts
×
UNCOV
48
        }
×
49

50
        return append(
×
51
                opts, btclog.WithStyledLevel(
×
52
                        func(l btclogv1.Level) string {
×
53
                                return styleString(
×
54
                                        fmt.Sprintf("[%s]", l),
×
55
                                        boldSeq,
×
56
                                        string(ansiColoSeq(l)),
×
57
                                )
×
58
                        },
×
59
                ),
60
                btclog.WithStyledCallSite(
61
                        func(file string, line int) string {
×
62
                                str := fmt.Sprintf("%s:%d", file, line)
×
63

×
64
                                return styleString(str, faintSeq)
×
65
                        },
×
66
                ),
67
                btclog.WithStyledKeys(func(key string) string {
×
68
                        return styleString(key, faintSeq)
×
69
                }),
×
70
        )
71
}
72

73
func styleString(s string, styles ...string) string {
×
74
        if len(styles) == 0 {
×
75
                return s
×
76
        }
×
77

78
        seq := strings.Join(styles, ";")
×
79
        if seq == "" {
×
80
                return s
×
81
        }
×
82

83
        return fmt.Sprintf("%s%sm%s%sm", csi, seq, s, csi+resetSeq)
×
84
}
85

86
type ansiColorSeq string
87

88
const (
89
        ansiColorSeqDarkTeal  ansiColorSeq = "38;5;30"
90
        ansiColorSeqDarkBlue  ansiColorSeq = "38;5;63"
91
        ansiColorSeqLightBlue ansiColorSeq = "38;5;86"
92
        ansiColorSeqYellow    ansiColorSeq = "38;5;192"
93
        ansiColorSeqRed       ansiColorSeq = "38;5;204"
94
        ansiColorSeqPink      ansiColorSeq = "38;5;134"
95
)
96

97
func ansiColoSeq(l btclogv1.Level) ansiColorSeq {
×
98
        switch l {
×
99
        case btclog.LevelTrace:
×
100
                return ansiColorSeqDarkTeal
×
101
        case btclog.LevelDebug:
×
102
                return ansiColorSeqDarkBlue
×
103
        case btclog.LevelWarn:
×
104
                return ansiColorSeqYellow
×
105
        case btclog.LevelError:
×
106
                return ansiColorSeqRed
×
107
        case btclog.LevelCritical:
×
108
                return ansiColorSeqPink
×
109
        default:
×
110
                return ansiColorSeqLightBlue
×
111
        }
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