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

lightningnetwork / lnd / 12293715361

12 Dec 2024 09:38AM UTC coverage: 57.483% (+7.9%) from 49.538%
12293715361

Pull #9348

github

ziggie1984
github: update goveralls tool

The goverall tool had a bug regarding the module versioning of
golang packages see also
https://github.com/mattn/goveralls/pull/222 for more background.
Goveralls is wrapped by another library to make it available for
github actions. So the relevant PR which is referenced here in
LND is:
https://github.com/shogo82148/actions-goveralls/pull/521.
Pull Request #9348: github: update goveralls tool

101897 of 177264 relevant lines covered (57.48%)

24982.4 hits per line

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

58.33
/contractcourt/breach_resolver.go
1
package contractcourt
2

3
import (
4
        "encoding/binary"
5
        "io"
6

7
        "github.com/lightningnetwork/lnd/channeldb"
8
)
9

10
// breachResolver is a resolver that will handle breached closes. In the
11
// future, this will likely take over the duties the current BreachArbitrator
12
// has.
13
type breachResolver struct {
14
        // resolved reflects if the contract has been fully resolved or not.
15
        resolved bool
16

17
        // subscribed denotes whether or not the breach resolver has subscribed
18
        // to the BreachArbitrator for breach resolution.
19
        subscribed bool
20

21
        // replyChan is closed when the breach arbiter has completed serving
22
        // justice.
23
        replyChan chan struct{}
24

25
        contractResolverKit
26
}
27

28
// newBreachResolver instantiates a new breach resolver.
29
func newBreachResolver(resCfg ResolverConfig) *breachResolver {
2✔
30
        r := &breachResolver{
2✔
31
                contractResolverKit: *newContractResolverKit(resCfg),
2✔
32
                replyChan:           make(chan struct{}),
2✔
33
        }
2✔
34

2✔
35
        r.initLogger(r)
2✔
36

2✔
37
        return r
2✔
38
}
2✔
39

40
// ResolverKey returns the unique identifier for this resolver.
41
func (b *breachResolver) ResolverKey() []byte {
4✔
42
        key := newResolverID(b.ChanPoint)
4✔
43
        return key[:]
4✔
44
}
4✔
45

46
// Resolve queries the BreachArbitrator to see if the justice transaction has
47
// been broadcast.
48
//
49
// TODO(yy): let sweeper handle the breach inputs.
50
func (b *breachResolver) Resolve(_ bool) (ContractResolver, error) {
2✔
51
        if !b.subscribed {
4✔
52
                complete, err := b.SubscribeBreachComplete(
2✔
53
                        &b.ChanPoint, b.replyChan,
2✔
54
                )
2✔
55
                if err != nil {
2✔
56
                        return nil, err
×
57
                }
×
58

59
                // If the breach resolution process is already complete, then
60
                // we can cleanup and checkpoint the resolved state.
61
                if complete {
2✔
62
                        b.resolved = true
×
63
                        return nil, b.Checkpoint(b)
×
64
                }
×
65

66
                // Prevent duplicate subscriptions.
67
                b.subscribed = true
2✔
68
        }
69

70
        select {
2✔
71
        case <-b.replyChan:
2✔
72
                // The replyChan has been closed, signalling that the breach
2✔
73
                // has been fully resolved. Checkpoint the resolved state and
2✔
74
                // exit.
2✔
75
                b.resolved = true
2✔
76
                return nil, b.Checkpoint(b)
2✔
77
        case <-b.quit:
×
78
        }
79

80
        return nil, errResolverShuttingDown
×
81
}
82

83
// Stop signals the breachResolver to stop.
84
func (b *breachResolver) Stop() {
2✔
85
        close(b.quit)
2✔
86
}
2✔
87

88
// IsResolved returns true if the breachResolver is fully resolved and cleanup
89
// can occur.
90
func (b *breachResolver) IsResolved() bool {
6✔
91
        return b.resolved
6✔
92
}
6✔
93

94
// SupplementState adds additional state to the breachResolver.
95
func (b *breachResolver) SupplementState(_ *channeldb.OpenChannel) {
×
96
}
×
97

98
// Encode encodes the breachResolver to the passed writer.
99
func (b *breachResolver) Encode(w io.Writer) error {
×
100
        return binary.Write(w, endian, b.resolved)
×
101
}
×
102

103
// newBreachResolverFromReader attempts to decode an encoded breachResolver
104
// from the passed Reader instance, returning an active breachResolver.
105
func newBreachResolverFromReader(r io.Reader, resCfg ResolverConfig) (
106
        *breachResolver, error) {
×
107

×
108
        b := &breachResolver{
×
109
                contractResolverKit: *newContractResolverKit(resCfg),
×
110
                replyChan:           make(chan struct{}),
×
111
        }
×
112

×
113
        if err := binary.Read(r, endian, &b.resolved); err != nil {
×
114
                return nil, err
×
115
        }
×
116

117
        b.initLogger(b)
×
118

×
119
        return b, nil
×
120
}
121

122
// A compile time assertion to ensure breachResolver meets the ContractResolver
123
// interface.
124
var _ ContractResolver = (*breachResolver)(nil)
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