swarm/network: Wait in processDeliveries until hash is ready

This commit is contained in:
Balint Gabor 2018-01-12 20:04:37 +01:00
parent 2efb994c19
commit 1c7805bde4

View file

@ -72,11 +72,13 @@ func NewRetrieveRequestStreamer(db *DbAccess) *RetrieveRequestStreamer {
// processDeliveries handles delivered chunk hashes // processDeliveries handles delivered chunk hashes
func (s *RetrieveRequestStreamer) processDeliveries() { func (s *RetrieveRequestStreamer) processDeliveries() {
var hashes []byte var hashes []byte
var batchC chan []byte
for { for {
select { select {
case delivery := <-s.deliveryC: case delivery := <-s.deliveryC:
hashes = append(hashes, delivery.Key[:]...) hashes = append(hashes, delivery.Key[:]...)
case s.batchC <- hashes: batchC = s.batchC
case batchC <- hashes:
hashes = nil hashes = nil
} }
} }