light: for range

This commit is contained in:
Zsolt Felfoldi 2018-08-15 21:14:35 +02:00
parent 5a37b923fa
commit 7b55bb2dcd

View file

@ -294,11 +294,7 @@ func (b *BloomTrieIndexerBackend) fetchMissingNodes(ctx context.Context, section
resCh := make(chan res, types.BloomBitLength) resCh := make(chan res, types.BloomBitLength)
for i := 0; i < 20; i++ { for i := 0; i < 20; i++ {
go func() { go func() {
for { for bitIndex := range indexCh {
bitIndex, ok := <-indexCh
if !ok {
return
}
r := &BloomRequest{BloomTrieRoot: root, BloomTrieNum: section - 1, BitIdx: bitIndex, SectionIdxList: []uint64{section - 1}} r := &BloomRequest{BloomTrieRoot: root, BloomTrieNum: section - 1, BitIdx: bitIndex, SectionIdxList: []uint64{section - 1}}
for { for {
if err := b.odr.Retrieve(ctx, r); err == ErrNoPeers { if err := b.odr.Retrieve(ctx, r); err == ErrNoPeers {