github-vet / github-vet/rangeloop-pointer-findings
BoltzExchange/boltz-lnd: nursery/swap.go; 39 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [BoltzExchange/boltz-lnd](https://www.github.com/BoltzExchange/boltz-lnd) at [nursery/swap.go](https://github.com/BoltzExchange/boltz-lnd/blob/f749b2202bfafd4889871b2c2da6cadb903c2447/nursery/swap.go#L181-L219)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> function call which takes a reference to swap at line 211 may start a goroutine
[Click here to see the code in its original context.](https://github.com/BoltzExchange/boltz-lnd/blob/f749b2202bfafd4889871b2c2da6cadb903c2447/nursery/swap.go#L181-L219)
Click here to show the 39 line(s) of Go which triggered the analyzer.
```go
for _, swap := range swaps {
channelCreation, err := nursery.database.QueryChannelCreation(swap.Id)
isChannelCreation := err == nil
swapType := getSwapType(isChannelCreation)
logger.Info("Recovering " + swapType + " " + swap.Id + " at state: " + swap.Status.String())
// TODO: handle race condition when status is updated between the POST request and the time the streaming starts
status, err := nursery.boltz.SwapStatus(swap.Id)
if err != nil {
logger.Warning("Boltz could not find Swap " + swap.Id + ": " + err.Error())
continue
}
if status.Status != swap.Status.String() {
logger.Info(swapType + " " + swap.Id + " status changed to: " + status.Status)
nursery.handleSwapStatus(&swap, channelCreation, *status)
isCompleted := false
for _, completedStatus := range boltz.CompletedStatus {
if swap.Status.String() == completedStatus {
isCompleted = true
break
}
}
if !isCompleted {
nursery.RegisterSwap(&swap, channelCreation)
}
continue
}
logger.Info(swapType + " " + swap.Id + " status did not change")
nursery.RegisterSwap(&swap, channelCreation)
}
```
Click here to show extra information the analyzer produced.
```
The following paths through the callgraph could lead to a goroutine:
(RegisterSwap, 2) -> (streamSwapStatus, 5) -> (StreamSwapStatus, 3) -> (streamSwapStatus, 3)
(RegisterSwap, 2)
(RegisterSwap, 2) -> (subscribeChannelCreationInvoice, 2)
(RegisterSwap, 2) -> (streamSwapStatus, 5)
(RegisterSwap, 2) -> (subscribeChannelCreationInvoice, 2) -> (subscribeSingleInvoice, 4) -> (SubscribeSingleInvoice, 3)
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: f749b2202bfafd4889871b2c2da6cadb903c2447
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.