Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fb50f54

Browse files
committedOct 28, 2024
contractcourt: fix concurrent access to launched
1 parent b6fd5ef commit fb50f54

8 files changed

+13
-13
lines changed
 

‎contractcourt/anchor_resolver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ var _ ContractResolver = (*anchorResolver)(nil)
176176

177177
// Launch offers the anchor output to the sweeper.
178178
func (c *anchorResolver) Launch() error {
179-
if c.launched {
179+
if c.launched.Load() {
180180
c.log.Tracef("already launched")
181181
return nil
182182
}
183183

184184
c.log.Debugf("launching resolver...")
185-
c.launched = true
185+
c.launched.Store(true)
186186

187187
// If we're already resolved, then we can exit early.
188188
if c.IsResolved() {

‎contractcourt/breach_resolver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ var _ ContractResolver = (*breachResolver)(nil)
126126

127127
// TODO(yy): implement it once the outputs are offered to the sweeper.
128128
func (b *breachResolver) Launch() error {
129-
if b.launched {
129+
if b.launched.Load() {
130130
b.log.Tracef("already launched")
131131
return nil
132132
}
133133

134134
b.log.Debugf("launching resolver...")
135-
b.launched = true
135+
b.launched.Store(true)
136136

137137
return nil
138138
}

‎contractcourt/commit_sweep_resolver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,13 @@ var _ reportingContractResolver = (*commitSweepResolver)(nil)
361361

362362
// Launch constructs a commit input and offers it to the sweeper.
363363
func (c *commitSweepResolver) Launch() error {
364-
if c.launched {
364+
if c.launched.Load() {
365365
c.log.Tracef("already launched")
366366
return nil
367367
}
368368

369369
c.log.Debugf("launching resolver...")
370-
c.launched = true
370+
c.launched.Store(true)
371371

372372
// If we're already resolved, then we can exit early.
373373
if c.IsResolved() {

‎contractcourt/contract_resolver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type contractResolverKit struct {
131131

132132
// launched specifies whether the resolver has been launched. Calling
133133
// `Launch` will be a no-op if this is true.
134-
launched bool
134+
launched atomic.Bool
135135

136136
// resolved reflects if the contract has been fully resolved or not.
137137
resolved atomic.Bool

‎contractcourt/htlc_incoming_contest_resolver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (h *htlcIncomingContestResolver) processFinalHtlcFail() error {
8383
func (h *htlcIncomingContestResolver) Launch() error {
8484
// NOTE: we don't mark this resolver as launched as the inner resolver
8585
// will set it when it's launched.
86-
if h.launched {
86+
if h.launched.Load() {
8787
h.log.Tracef("already launched")
8888
return nil
8989
}

‎contractcourt/htlc_outgoing_contest_resolver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func newOutgoingContestResolver(res lnwallet.OutgoingHtlcResolution,
4040
func (h *htlcOutgoingContestResolver) Launch() error {
4141
// NOTE: we don't mark this resolver as launched as the inner resolver
4242
// will set it when it's launched.
43-
if h.launched {
43+
if h.launched.Load() {
4444
h.log.Tracef("already launched")
4545
return nil
4646
}

‎contractcourt/htlc_success_resolver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -725,13 +725,13 @@ func (h *htlcSuccessResolver) resolveSuccessTxOutput(op wire.OutPoint) error {
725725
// Launch creates an input based on the details of the incoming htlc resolution
726726
// and offers it to the sweeper.
727727
func (h *htlcSuccessResolver) Launch() error {
728-
if h.launched {
728+
if h.launched.Load() {
729729
h.log.Tracef("already launched")
730730
return nil
731731
}
732732

733733
h.log.Debugf("launching resolver...")
734-
h.launched = true
734+
h.launched.Store(true)
735735

736736
// If the HTLC has custom records, then for now we'll pause resolution.
737737
//

‎contractcourt/htlc_timeout_resolver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1228,13 +1228,13 @@ func (h *htlcTimeoutResolver) resolveTimeoutTxOutput(op wire.OutPoint) error {
12281228
// Launch creates an input based on the details of the outgoing htlc resolution
12291229
// and offers it to the sweeper.
12301230
func (h *htlcTimeoutResolver) Launch() error {
1231-
if h.launched {
1231+
if h.launched.Load() {
12321232
h.log.Tracef("already launched")
12331233
return nil
12341234
}
12351235

12361236
h.log.Debugf("launching resolver...")
1237-
h.launched = true
1237+
h.launched.Store(true)
12381238

12391239
// If the HTLC has custom records, then for now we'll pause resolution.
12401240
//

0 commit comments

Comments
 (0)
Please sign in to comment.