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
|
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)
|
||||||
|
|
||||||
switch {
|
if depth == 0 {
|
||||||
case 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)
|
||||||
|
|
@ -216,13 +215,11 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR
|
||||||
Data: data,
|
Data: data,
|
||||||
Size: size,
|
Size: size,
|
||||||
}
|
}
|
||||||
case size < treeSize:
|
} else {
|
||||||
parentWg.Add(1)
|
for size < treeSize {
|
||||||
// last item on this level (== size % self.Branches ^ (depth + 1) )
|
treeSize /= self.Branches
|
||||||
self.split(depth-1, treeSize/self.Branches, key, data, chunkC, errc, parentWg)
|
depth--
|
||||||
return
|
}
|
||||||
|
|
||||||
default:
|
|
||||||
// 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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue