github-vet / github-vet/rangeloop-pointer-findings
QOSGroup/qmoon: service/block_validator.go; 36 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [QOSGroup/qmoon](https://www.github.com/QOSGroup/qmoon) at [service/block_validator.go](https://github.com/QOSGroup/qmoon/blob/c9564dd94e195737487ac93754da3831745dc468/service/block_validator.go#L253-L288)
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.
> reference to v is reassigned at line 254
[Click here to see the code in its original context.](https://github.com/QOSGroup/qmoon/blob/c9564dd94e195737487ac93754da3831745dc468/service/block_validator.go#L253-L288)
Click here to show the 36 line(s) of Go which triggered the analyzer.
```go
for _, v := range allVals {
validatorsInDB[v.Address] = &v
if _, ok := vm[v.Address]; !ok {
missing := &models.Missing{
Height: height,
ValidatorAddress: v.Address,
CreatedAt: t,
}
missing.Insert(n.ChainID)
vh := &models.ValidatorHistoryRecord{
Height: height,
Address: v.Address,
VotingPower: v.VotingPower,
TotalPower: total,
Status: 1,
}
err = vh.Insert(n.ChainID)
if err!= nil {
fmt.Println("error insert block validator:", vh)
}
} else {
vh := &models.ValidatorHistoryRecord{
Height: height,
Address: v.Address,
VotingPower: v.VotingPower,
TotalPower: total,
Status: 0,
}
err = vh.Insert(n.ChainID)
if err!= nil {
fmt.Println("error insert block validator:", vh)
}
}
}
```
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: c9564dd94e195737487ac93754da3831745dc468
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.