mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 12:16:44 +00:00
fix redundancy in join + comment out logging in chunker
This commit is contained in:
parent
667c59f81a
commit
bcbaada9b8
1 changed files with 9 additions and 16 deletions
|
|
@ -107,7 +107,7 @@ func (self *TreeChunker) Init() {
|
||||||
}
|
}
|
||||||
self.hashSize = int64(self.HashFunc.New().Size())
|
self.hashSize = int64(self.HashFunc.New().Size())
|
||||||
self.chunkSize = self.hashSize * self.Branches
|
self.chunkSize = self.hashSize * self.Branches
|
||||||
dpaLogger.Debugf("Chunker initialised: branches: %v, hashsize: %v, chunksize: %v, join timeout: %v , split timeout: %v", self.Branches, self.hashSize, self.chunkSize, self.JoinTimeout, self.SplitTimeout)
|
//dpaLogger.Debugf("Chunker initialised: branches: %v, hashsize: %v, chunksize: %v, join timeout: %v , split timeout: %v", self.Branches, self.hashSize, self.chunkSize, self.JoinTimeout, self.SplitTimeout)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +161,7 @@ func (self *TreeChunker) Split(key Key, data SectionReader, chunkC chan *Chunk)
|
||||||
rerrC := make(chan error)
|
rerrC := make(chan error)
|
||||||
timeout := time.After(splitTimeout)
|
timeout := time.After(splitTimeout)
|
||||||
if key == nil {
|
if key == nil {
|
||||||
dpaLogger.Debugf("please allocate byte slice for root key")
|
//dpaLogger.Debugf("please allocate byte slice for root key")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
@ -177,7 +177,7 @@ func (self *TreeChunker) Split(key Key, data SectionReader, chunkC chan *Chunk)
|
||||||
depth++
|
depth++
|
||||||
}
|
}
|
||||||
|
|
||||||
dpaLogger.Debugf("split request received for data (%v bytes, depth: %v)", size, depth)
|
//dpaLogger.Debugf("split request received for data (%v bytes, depth: %v)", size, depth)
|
||||||
|
|
||||||
//launch actual recursive function passing the workgroup
|
//launch actual recursive function passing the workgroup
|
||||||
self.split(depth, treeSize/self.Branches, key, data, chunkC, rerrC, wg)
|
self.split(depth, treeSize/self.Branches, key, data, chunkC, rerrC, wg)
|
||||||
|
|
@ -213,7 +213,7 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR
|
||||||
size := data.Size()
|
size := data.Size()
|
||||||
var newChunk *Chunk
|
var newChunk *Chunk
|
||||||
var hash Key
|
var hash Key
|
||||||
dpaLogger.Debugf("depth: %v, max subtree size: %v, data size: %v", depth, treeSize, size)
|
//dpaLogger.Debugf("depth: %v, max subtree size: %v, data size: %v", depth, treeSize, size)
|
||||||
|
|
||||||
for depth > 0 && size < treeSize {
|
for depth > 0 && size < treeSize {
|
||||||
treeSize /= self.Branches
|
treeSize /= self.Branches
|
||||||
|
|
@ -223,7 +223,7 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
// leaf nodes -> content chunks
|
// leaf nodes -> content chunks
|
||||||
hash = self.Hash(size, data)
|
hash = self.Hash(size, data)
|
||||||
dpaLogger.Debugf("content chunk: max subtree size: %v, data size: %v", treeSize, size)
|
//dpaLogger.Debugf("content chunk: max subtree size: %v, data size: %v", treeSize, size)
|
||||||
newChunk = &Chunk{
|
newChunk = &Chunk{
|
||||||
Key: hash,
|
Key: hash,
|
||||||
Data: data,
|
Data: data,
|
||||||
|
|
@ -232,7 +232,7 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR
|
||||||
} else {
|
} else {
|
||||||
// intermediate chunk containing child nodes hashes
|
// intermediate chunk containing child nodes hashes
|
||||||
branches := int64((size-1)/treeSize) + 1
|
branches := int64((size-1)/treeSize) + 1
|
||||||
dpaLogger.Debugf("intermediate node: setting branches: %v, depth: %v, max subtree size: %v, data size: %v", branches, depth, treeSize, size)
|
//dpaLogger.Debugf("intermediate node: setting branches: %v, depth: %v, max subtree size: %v, data size: %v", branches, depth, treeSize, size)
|
||||||
|
|
||||||
var chunk []byte = make([]byte, branches*self.hashSize)
|
var chunk []byte = make([]byte, branches*self.hashSize)
|
||||||
var pos, i int64
|
var pos, i int64
|
||||||
|
|
@ -367,27 +367,21 @@ func (self *TreeChunker) join(depth int, treeSize int64, key Key, chunkC chan *C
|
||||||
}
|
}
|
||||||
// boooo
|
// boooo
|
||||||
// intermediate chunk, chunk containing hashes of child nodes
|
// intermediate chunk, chunk containing hashes of child nodes
|
||||||
var pos, i, secSize int64
|
var i int64
|
||||||
var childKey Key
|
var childKey Key
|
||||||
var readerF func() (r LazySectionReader)
|
var readerF func() (r LazySectionReader)
|
||||||
var readerFs [](func() (r LazySectionReader))
|
var readerFs [](func() (r LazySectionReader))
|
||||||
branches := int64((chunk.Size-1)/treeSize) + 1
|
branches := int64((chunk.Size-1)/treeSize) + 1
|
||||||
dpaLogger.DebugDetailf("tree node - size %v, chunk size: %v, subtreeSize %v, branches %v", chunk.Size, chunk.Data.Size(), treeSize, branches)
|
//dpaLogger.DebugDetailf("tree node - size %v, chunk size: %v, subtreeSize %v, branches %v", chunk.Size, chunk.Data.Size(), treeSize, branches)
|
||||||
|
|
||||||
// iterate through the chunk containing the keys of children
|
// iterate through the chunk containing the keys of children
|
||||||
// create lazy init functions that give back readers
|
// create lazy init functions that give back readers
|
||||||
for i < branches {
|
for i < branches {
|
||||||
if chunk.Size-pos < treeSize {
|
|
||||||
secSize = chunk.Size - pos
|
|
||||||
dpaLogger.DebugDetailf("tree node section %v: size %v", i, secSize)
|
|
||||||
} else {
|
|
||||||
secSize = treeSize
|
|
||||||
}
|
|
||||||
// create partial Chunk in order to send a retrieval request
|
// create partial Chunk in order to send a retrieval request
|
||||||
childKey = make([]byte, self.hashSize) // preallocate hashSize long slice for key
|
childKey = make([]byte, self.hashSize) // preallocate hashSize long slice for key
|
||||||
// read the Hash of the subtree from the relevant section of the Chunk into the allocated byte slice in subtree.Key
|
// read the Hash of the subtree from the relevant section of the Chunk into the allocated byte slice in subtree.Key
|
||||||
if _, err := chunk.Data.ReadAt(childKey, i*self.hashSize); err != nil {
|
if _, err := chunk.Data.ReadAt(childKey, i*self.hashSize); err != nil {
|
||||||
dpaLogger.DebugDetailf("Read error: %v", err)
|
//dpaLogger.DebugDetailf("Read error: %v", err)
|
||||||
errC <- err
|
errC <- err
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -395,7 +389,6 @@ func (self *TreeChunker) join(depth int, treeSize int64, key Key, chunkC chan *C
|
||||||
readerF = self.join(depth-1, treeSize/self.Branches, childKey, chunkC, errC, wg, quitC)
|
readerF = self.join(depth-1, treeSize/self.Branches, childKey, chunkC, errC, wg, quitC)
|
||||||
readerFs = append(readerFs, readerF)
|
readerFs = append(readerFs, readerF)
|
||||||
i++
|
i++
|
||||||
pos += treeSize
|
|
||||||
}
|
}
|
||||||
// new reader created on demand:
|
// new reader created on demand:
|
||||||
r = &LazyChunkReader{
|
r = &LazyChunkReader{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue