mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 19:56:44 +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()
|
||||
sr := io.NewSectionReader(f, 0, stat.Size())
|
||||
hash := bzz.GetDPAhash(sr, nil)
|
||||
|
||||
fmt.Printf("%064x\n", hash)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,10 @@ func (self *TreeChunker) Init() {
|
|||
|
||||
}
|
||||
|
||||
func (self *TreeChunker) HashSize() int64 {
|
||||
return self.hashSize
|
||||
}
|
||||
|
||||
type Chunk struct {
|
||||
Data SectionReader // nil if request, to be supplied by dpa
|
||||
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
|
||||
chunkC <- newChunk
|
||||
if chunkC != nil {
|
||||
chunkC <- newChunk
|
||||
}
|
||||
// report hash of this chunk one level up (keys corresponds to the proper subslice of the parent chunk)x
|
||||
copy(key, hash)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue