mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
Fis storageWG in chunker
storeWG did not work because it was possible to start to wait on earlier than the first Add happened
This commit is contained in:
parent
1ad50b1563
commit
f3fdcb2064
1 changed files with 18 additions and 14 deletions
|
|
@ -130,7 +130,7 @@ func (self *TreeChunker) Split(data io.Reader, size int64, chunkC chan *Chunk) (
|
||||||
quitC := make(chan bool)
|
quitC := make(chan bool)
|
||||||
|
|
||||||
self.incrementWorkerCount()
|
self.incrementWorkerCount()
|
||||||
go self.hashWorker(jobC, chunkC, errC, quitC, storeWg)
|
self.runHashWorker(jobC, chunkC, errC, quitC, storeWg)
|
||||||
|
|
||||||
depth := 0
|
depth := 0
|
||||||
treeSize := self.chunkSize
|
treeSize := self.chunkSize
|
||||||
|
|
@ -230,7 +230,7 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data io.Reade
|
||||||
worker := self.getWorkerCount()
|
worker := self.getWorkerCount()
|
||||||
if int64(len(jobC)) > worker && worker < ChunkProcessors {
|
if int64(len(jobC)) > worker && worker < ChunkProcessors {
|
||||||
self.incrementWorkerCount()
|
self.incrementWorkerCount()
|
||||||
go self.hashWorker(jobC, chunkC, errC, quitC, storeWg)
|
self.runHashWorker(jobC, chunkC, errC, quitC, storeWg)
|
||||||
|
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
|
|
@ -239,23 +239,27 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data io.Reade
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *TreeChunker) hashWorker(jobC chan *hashJob, chunkC chan *Chunk, errC chan error, quitC chan bool, storeWg *sync.WaitGroup) {
|
func (self *TreeChunker) runHashWorker(jobC chan *hashJob, chunkC chan *Chunk, errC chan error, quitC chan bool, storeWg *sync.WaitGroup) {
|
||||||
defer self.decrementWorkerCount()
|
storeWg.Add(1)
|
||||||
|
|
||||||
hasher := self.hashFunc()
|
go func() {
|
||||||
for {
|
defer self.decrementWorkerCount()
|
||||||
select {
|
defer storeWg.Done()
|
||||||
|
hasher := self.hashFunc()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
|
||||||
case job, ok := <-jobC:
|
case job, ok := <-jobC:
|
||||||
if !ok {
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// now we got the hashes in the chunk, then hash the chunks
|
||||||
|
self.hashChunk(hasher, job, chunkC, storeWg)
|
||||||
|
case <-quitC:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// now we got the hashes in the chunk, then hash the chunks
|
|
||||||
self.hashChunk(hasher, job, chunkC, storeWg)
|
|
||||||
case <-quitC:
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// The treeChunkers own Hash hashes together
|
// The treeChunkers own Hash hashes together
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue