mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Recursion converted into loop
This commit is contained in:
parent
32ed5ba45d
commit
4ea99e804f
1 changed files with 6 additions and 9 deletions
|
|
@ -206,8 +206,7 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR
|
|||
var hash Key
|
||||
dpaLogger.Debugf("depth: %v, max subtree size: %v, data size: %v", depth, treeSize, size)
|
||||
|
||||
switch {
|
||||
case depth == 0:
|
||||
if depth == 0 {
|
||||
// leaf nodes -> content chunks
|
||||
hash = self.Hash(size, data)
|
||||
dpaLogger.Debugf("content chunk: max subtree size: %v, data size: %v", treeSize, size)
|
||||
|
|
@ -216,13 +215,11 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR
|
|||
Data: data,
|
||||
Size: size,
|
||||
}
|
||||
case size < treeSize:
|
||||
parentWg.Add(1)
|
||||
// last item on this level (== size % self.Branches ^ (depth + 1) )
|
||||
self.split(depth-1, treeSize/self.Branches, key, data, chunkC, errc, parentWg)
|
||||
return
|
||||
|
||||
default:
|
||||
} else {
|
||||
for size < treeSize {
|
||||
treeSize /= self.Branches
|
||||
depth--
|
||||
}
|
||||
// intermediate chunk containing child nodes hashes
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue