github-vet / github-vet/rangeloop-pointer-findings
EDXFund/MasterChain: eth/fetcher/fetcher.go; 21 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [EDXFund/MasterChain](https://www.github.com/EDXFund/MasterChain) at [eth/fetcher/fetcher.go](https://github.com/EDXFund/MasterChain/blob/6ad8bdd0f74aeedc74a3773f9e6d2a0f7b2e33b5/eth/fetcher/fetcher.go#L439-L459)
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 requestHash used in defer or goroutine at line 448
[Click here to see the code in its original context.](https://github.com/EDXFund/MasterChain/blob/6ad8bdd0f74aeedc74a3773f9e6d2a0f7b2e33b5/eth/fetcher/fetcher.go#L439-L459)
Click here to show the 21 line(s) of Go which triggered the analyzer.
```go
for peer, requestHash := range request {
fmt.Println("Fetching scheduled headers", "peer", peer, "list", requestHash)
// Create a closure of the fetch and schedule in on a new thread
fetchHeader := f.fetching[requestHash[0].hash].fetchHeader
go func() {
if f.fetchingHook != nil {
hashs := []common.Hash{}
var shardId uint16
for _, rhash := range requestHash {
shardId = rhash.shardId
hashs = append(hashs, rhash.hash) // Suboptimal, but protocol doesn't allow batch header retrievals
}
f.fetchingHook(hashs, shardId)
}
for _, rhash := range requestHash {
headerFetchMeter.Mark(1)
fetchHeader(rhash.hash, rhash.shardId) // 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: 6ad8bdd0f74aeedc74a3773f9e6d2a0f7b2e33b5
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.