mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
Merge f809fa5941 into 73067fd24f
This commit is contained in:
commit
3bc264f8a0
1 changed files with 5 additions and 3 deletions
|
|
@ -43,11 +43,14 @@ type chunkerTester struct {
|
||||||
inputs map[uint64][]byte
|
inputs map[uint64][]byte
|
||||||
chunks map[string]*Chunk
|
chunks map[string]*Chunk
|
||||||
t test
|
t test
|
||||||
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *chunkerTester) Split(chunker Splitter, data io.Reader, size int64, chunkC chan *Chunk, swg *sync.WaitGroup, expectedError error) (key Key, err error) {
|
func (self *chunkerTester) Split(chunker Splitter, data io.Reader, size int64, chunkC chan *Chunk, swg *sync.WaitGroup, expectedError error) (key Key, err error) {
|
||||||
// reset
|
// reset
|
||||||
|
self.lock.Lock()
|
||||||
self.chunks = make(map[string]*Chunk)
|
self.chunks = make(map[string]*Chunk)
|
||||||
|
self.lock.Unlock()
|
||||||
|
|
||||||
if self.inputs == nil {
|
if self.inputs == nil {
|
||||||
self.inputs = make(map[uint64][]byte)
|
self.inputs = make(map[uint64][]byte)
|
||||||
|
|
@ -65,7 +68,9 @@ func (self *chunkerTester) Split(chunker Splitter, data io.Reader, size int64, c
|
||||||
return nil
|
return nil
|
||||||
case chunk := <-chunkC:
|
case chunk := <-chunkC:
|
||||||
// self.chunks = append(self.chunks, chunk)
|
// self.chunks = append(self.chunks, chunk)
|
||||||
|
self.lock.Lock()
|
||||||
self.chunks[chunk.Key.String()] = chunk
|
self.chunks[chunk.Key.String()] = chunk
|
||||||
|
self.lock.Unlock()
|
||||||
if chunk.wg != nil {
|
if chunk.wg != nil {
|
||||||
chunk.wg.Done()
|
chunk.wg.Done()
|
||||||
}
|
}
|
||||||
|
|
@ -81,9 +86,6 @@ func (self *chunkerTester) Split(chunker Splitter, data io.Reader, size int64, c
|
||||||
}
|
}
|
||||||
|
|
||||||
if chunkC != nil {
|
if chunkC != nil {
|
||||||
if swg != nil {
|
|
||||||
swg.Wait()
|
|
||||||
}
|
|
||||||
close(quitC)
|
close(quitC)
|
||||||
}
|
}
|
||||||
return key, err
|
return key, err
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue