swarm/network/master: protect SetNextBatch iterator after close (#19147)

This commit is contained in:
Janoš Guljaš
2019-02-21 18:33:49 +01:00
committed by Viktor Trón
parent b9808e392f
commit 836c846812
2 changed files with 15 additions and 0 deletions

View File

@@ -107,6 +107,11 @@ func (s *SwarmSyncerServer) SetNextBatch(from, to uint64) ([]byte, uint64, uint6
metrics.GetOrRegisterCounter("syncer.setnextbatch.iterator", nil).Inc(1)
err := s.store.Iterator(from, to, s.po, func(key storage.Address, idx uint64) bool {
select {
case <-s.quit:
return false
default:
}
batch = append(batch, key[:]...)
i++
to = idx