github-vet / github-vet/rangeloop-pointer-findings
coco1101/hnode: synctrl/puller.go; 15 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [coco1101/hnode](https://www.github.com/coco1101/hnode) at [synctrl/puller.go](https://github.com/coco1101/hnode/blob/a158b95acf5b17563646fa523734065444c5b77b/synctrl/puller.go#L381-L395)
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.
> range-loop variable peer used in defer or goroutine at line 392
[Click here to see the code in its original context.](https://github.com/coco1101/hnode/blob/a158b95acf5b17563646fa523734065444c5b77b/synctrl/puller.go#L381-L395)
Click here to show the 15 line(s) of Go which triggered the analyzer.
```go
for peer, hashes := range request {
log.Trace("Fetching scheduled headers", "peer", peer, "list", hashes)
// Create a closure of the fetch and schedule in on a new thread
fetchHeader, hashes := this.fetching[hashes[0]].fetchHeader, hashes
go func() {
if this.fetchingHook != nil {
this.fetchingHook(hashes)
}
for _, hash := range hashes {
headerFetchMeter.Mark(1)
fetchHeader(p2p.PeerMgrInst().Peer(peer), hash) // Suboptimal, but protocol doesn't allow batch header retrievals
}
}()
}
```
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: a158b95acf5b17563646fa523734065444c5b77b
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.