mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
chunker perpared for nil chunk channel, bzzhash from bzz-fefe modified for chunker API
This commit is contained in:
parent
463b056518
commit
b710ad9568
2 changed files with 20 additions and 4 deletions
|
|
@ -22,7 +22,17 @@ func main() {
|
||||||
|
|
||||||
stat, _ := f.Stat()
|
stat, _ := f.Stat()
|
||||||
sr := io.NewSectionReader(f, 0, stat.Size())
|
sr := io.NewSectionReader(f, 0, stat.Size())
|
||||||
hash := bzz.GetDPAhash(sr, nil)
|
chunker := &bzz.TreeChunker{
|
||||||
|
Branches: 128,
|
||||||
|
}
|
||||||
|
chunker.Init()
|
||||||
|
hash := make([]byte, chunker.HashSize())
|
||||||
|
errC := chunker.Split(hash, sr, nil)
|
||||||
|
err, ok := <-errC
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
fmt.Printf("%064x\n", hash)
|
fmt.Printf("%064x\n", hash)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,10 @@ func (self *TreeChunker) Init() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *TreeChunker) HashSize() int64 {
|
||||||
|
return self.hashSize
|
||||||
|
}
|
||||||
|
|
||||||
type Chunk struct {
|
type Chunk struct {
|
||||||
Data SectionReader // nil if request, to be supplied by dpa
|
Data SectionReader // nil if request, to be supplied by dpa
|
||||||
Size int64 // size of the data covered by the subtree encoded in this chunk
|
Size int64 // size of the data covered by the subtree encoded in this chunk
|
||||||
|
|
@ -258,7 +262,9 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// send off new chunk to storage
|
// send off new chunk to storage
|
||||||
|
if chunkC != nil {
|
||||||
chunkC <- newChunk
|
chunkC <- newChunk
|
||||||
|
}
|
||||||
// report hash of this chunk one level up (keys corresponds to the proper subslice of the parent chunk)x
|
// report hash of this chunk one level up (keys corresponds to the proper subslice of the parent chunk)x
|
||||||
copy(key, hash)
|
copy(key, hash)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue