Skip to content

Commit 3a47a0f

Browse files
committed
Context check: Fix client
Signed-off-by: Matthias Geihs <matthias@perun.network>
1 parent 3dd1838 commit 3a47a0f

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

client/proposal.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ func (c *Client) ProposeChannel(ctx context.Context, prop ChannelProposal) (*Cha
165165
}
166166

167167
// 2. send proposal, wait for response, create channel object
168-
c.enableVer1Cache() // cache version 1 updates until channel is opened
169-
defer c.releaseVer1Cache() // replay cached version 1 updates
168+
// cache version 1 updates until channel is opened
169+
c.enableVer1Cache()
170+
// replay cached version 1 updates
171+
defer c.releaseVer1Cache() //nolint:contextcheck
170172
ch, err := c.proposeTwoPartyChannel(ctx, prop)
171173
if err != nil {
172174
return nil, errors.WithMessage(err, "channel proposal")
@@ -236,8 +238,10 @@ func (c *Client) handleChannelProposalAcc(
236238
return ch, errors.WithMessage(err, "validating channel proposal acceptance")
237239
}
238240

239-
c.enableVer1Cache() // cache version 1 updates
240-
defer c.releaseVer1Cache() // replay cached version 1 updates
241+
// cache version 1 updates
242+
c.enableVer1Cache()
243+
// replay cached version 1 updates
244+
defer c.releaseVer1Cache() //nolint:contextcheck
241245

242246
if ch, err = c.acceptChannelProposal(ctx, prop, p, acc); err != nil {
243247
return ch, errors.WithMessage(err, "accept channel proposal")
@@ -700,7 +704,7 @@ func (c *Client) releaseVer1Cache() {
700704

701705
c.version1Cache.enabled--
702706
for _, u := range c.version1Cache.cache {
703-
go c.handleChannelUpdate(u.uh, u.p, u.m)
707+
go c.handleChannelUpdate(u.uh, u.p, u.m) //nolint:contextcheck
704708
}
705709
c.version1Cache.cache = nil
706710
}

client/update.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (c *Client) handleChannelUpdate(uh UpdateHandler, p wire.Address, m Channel
4141
return
4242
}
4343
pidx := ch.Idx() ^ 1
44-
ch.handleUpdateReq(pidx, m, uh)
44+
ch.handleUpdateReq(pidx, m, uh) //nolint:contextcheck
4545
}
4646

4747
func (c *Client) cacheVersion1Update(uh UpdateHandler, p wire.Address, m ChannelUpdateProposal) bool {
@@ -288,12 +288,12 @@ func (c *Channel) handleUpdateReq(
288288
client := c.client
289289

290290
if prop, ok := req.(*virtualChannelFundingProposal); ok {
291-
client.handleVirtualChannelFundingProposal(c, prop, responder)
291+
client.handleVirtualChannelFundingProposal(c, prop, responder) //nolint:contextcheck
292292
return
293293
}
294294

295295
if prop, ok := req.(*virtualChannelSettlementProposal); ok {
296-
client.handleVirtualChannelSettlementProposal(c, prop, responder)
296+
client.handleVirtualChannelSettlementProposal(c, prop, responder) //nolint:contextcheck
297297
return
298298
}
299299

client/virtual_channel.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ func (c *Client) handleVirtualChannelFundingProposal(
9090
) {
9191
err := c.validateVirtualChannelFundingProposal(ch, prop)
9292
if err != nil {
93-
c.rejectProposal(responder, err.Error())
93+
c.rejectProposal(responder, err.Error()) //nolint:contextcheck
9494
}
9595

9696
ctx, cancel := context.WithTimeout(c.Ctx(), virtualFundingTimeout)
9797
defer cancel()
9898

9999
err = c.fundingWatcher.Await(ctx, prop)
100100
if err != nil {
101-
c.rejectProposal(responder, err.Error())
101+
c.rejectProposal(responder, err.Error()) //nolint:contextcheck
102102
}
103103

104-
c.acceptProposal(responder)
104+
c.acceptProposal(responder) //nolint:contextcheck
105105
}
106106

107107
func (c *Channel) watchVirtual() error {
@@ -348,7 +348,7 @@ func (c *Client) matchFundingProposal(ctx context.Context, a, b interface{}) boo
348348
}
349349

350350
go func() {
351-
err := virtual.watchVirtual()
351+
err := virtual.watchVirtual() //nolint:contextcheck // The context will be derived from the channel context.
352352
c.log.Debugf("channel %v: watcher stopped: %v", virtual.ID(), err)
353353
}()
354354
return true

client/virtual_channel_settlement.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (c *Client) handleVirtualChannelSettlementProposal(
7979
) {
8080
err := c.validateVirtualChannelSettlementProposal(parent, prop)
8181
if err != nil {
82-
c.rejectProposal(responder, err.Error())
82+
c.rejectProposal(responder, err.Error()) //nolint:contextcheck
8383
}
8484

8585
ctx, cancel := context.WithTimeout(c.Ctx(), virtualSettlementTimeout)
@@ -90,7 +90,7 @@ func (c *Client) handleVirtualChannelSettlementProposal(
9090
resp: responder,
9191
})
9292
if err != nil {
93-
c.rejectProposal(responder, err.Error())
93+
c.rejectProposal(responder, err.Error()) //nolint:contextcheck
9494
}
9595
}
9696

0 commit comments

Comments
 (0)