mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
fix pos update in recursive join, put size instead of treeSize into the non-leaf chunks
This commit is contained in:
parent
bee2d91955
commit
9897c64186
2 changed files with 9 additions and 6 deletions
|
|
@ -252,11 +252,11 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR
|
||||||
childrenWg.Wait()
|
childrenWg.Wait()
|
||||||
// now we got the hashes in the chunk, then hash the chunk
|
// now we got the hashes in the chunk, then hash the chunk
|
||||||
chunkReader := NewChunkReaderFromBytes(chunk) // bytes.Reader almost implements SectionReader
|
chunkReader := NewChunkReaderFromBytes(chunk) // bytes.Reader almost implements SectionReader
|
||||||
hash = self.Hash(treeSize, chunkReader)
|
hash = self.Hash(size, chunkReader)
|
||||||
newChunk = &Chunk{
|
newChunk = &Chunk{
|
||||||
Key: hash,
|
Key: hash,
|
||||||
Data: chunkReader,
|
Data: chunkReader,
|
||||||
Size: treeSize,
|
Size: size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// send off new chunk to storage
|
// send off new chunk to storage
|
||||||
|
|
@ -329,7 +329,7 @@ func (self *TreeChunker) Join(key Key, data SectionWriter) (chunkC chan *Chunk,
|
||||||
depth++
|
depth++
|
||||||
}
|
}
|
||||||
// launch recursive call on root chunk
|
// launch recursive call on root chunk
|
||||||
self.join(depth, treeSize, chunk, data, chunkC, rerrC, wg, quitC)
|
self.join(depth, treeSize/self.Branches, chunk, data, chunkC, rerrC, wg, quitC)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// waits for all the processes to finish and signals by closing internal rerrc
|
// waits for all the processes to finish and signals by closing internal rerrc
|
||||||
|
|
@ -365,7 +365,10 @@ func (self *TreeChunker) join(depth int, treeSize int64, chunk *Chunk, data Sect
|
||||||
case <-chunk.C: // bells are ringing, data have been delivered
|
case <-chunk.C: // bells are ringing, data have been delivered
|
||||||
dpaLogger.Debugf("received chunk data: %v", chunk)
|
dpaLogger.Debugf("received chunk data: %v", chunk)
|
||||||
switch {
|
switch {
|
||||||
case chunk.Size <= treeSize && depth == 0:
|
case depth == 0:
|
||||||
|
if chunk.Size > self.chunkSize {
|
||||||
|
panic("oops")
|
||||||
|
}
|
||||||
dpaLogger.Debugf("reading into data")
|
dpaLogger.Debugf("reading into data")
|
||||||
// we received a chunk for a leaf node representing actual content
|
// we received a chunk for a leaf node representing actual content
|
||||||
if _, err := data.ReadFrom(chunk.Data); err != nil {
|
if _, err := data.ReadFrom(chunk.Data); err != nil {
|
||||||
|
|
@ -394,7 +397,7 @@ func (self *TreeChunker) join(depth int, treeSize int64, chunk *Chunk, data Sect
|
||||||
// submit request
|
// submit request
|
||||||
chunkC <- subtree
|
chunkC <- subtree
|
||||||
i++
|
i++
|
||||||
pos += subtree.Size
|
pos += treeSize
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ func TestChunker1(t *testing.T) {
|
||||||
chunker.Init()
|
chunker.Init()
|
||||||
tester := &chunkerTester{}
|
tester := &chunkerTester{}
|
||||||
key, input := tester.Split(chunker, 70)
|
key, input := tester.Split(chunker, 70)
|
||||||
tester.checkChunks(t, 2)
|
tester.checkChunks(t, 3)
|
||||||
t.Logf("chunks: %v", tester.chunks)
|
t.Logf("chunks: %v", tester.chunks)
|
||||||
output := tester.Join(t, chunker, key)
|
output := tester.Join(t, chunker, key)
|
||||||
if bytes.Compare(output, input) != 0 {
|
if bytes.Compare(output, input) != 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue