Commit 222445c9 authored by rht's avatar rht Committed by Jeromy

Remove chunk channels

License: MIT
Signed-off-by: default avatarrht <rhtbot@gmail.com>
parent 90f6f5f0
...@@ -103,8 +103,7 @@ func (zr zeroReader) Read(b []byte) (int, error) { ...@@ -103,8 +103,7 @@ func (zr zeroReader) Read(b []byte) (int, error) {
func (dm *DagModifier) expandSparse(size int64) error { func (dm *DagModifier) expandSparse(size int64) error {
r := io.LimitReader(zeroReader{}, size) r := io.LimitReader(zeroReader{}, size)
spl := chunk.NewSizeSplitter(r, 4096) spl := chunk.NewSizeSplitter(r, 4096)
blks, errs := chunk.Chan(spl) nnode, err := dm.appendData(dm.curNode, spl)
nnode, err := dm.appendData(dm.curNode, blks, errs)
if err != nil { if err != nil {
return err return err
} }
...@@ -191,8 +190,7 @@ func (dm *DagModifier) Sync() error { ...@@ -191,8 +190,7 @@ func (dm *DagModifier) Sync() error {
// need to write past end of current dag // need to write past end of current dag
if !done { if !done {
blks, errs := chunk.Chan(dm.splitter(dm.wrBuf)) nd, err = dm.appendData(dm.curNode, dm.splitter(dm.wrBuf))
nd, err = dm.appendData(dm.curNode, blks, errs)
if err != nil { if err != nil {
return err return err
} }
...@@ -286,13 +284,13 @@ func (dm *DagModifier) modifyDag(node *mdag.Node, offset uint64, data io.Reader) ...@@ -286,13 +284,13 @@ func (dm *DagModifier) modifyDag(node *mdag.Node, offset uint64, data io.Reader)
} }
// appendData appends the blocks from the given chan to the end of this dag // appendData appends the blocks from the given chan to the end of this dag
func (dm *DagModifier) appendData(node *mdag.Node, blks <-chan []byte, errs <-chan error) (*mdag.Node, error) { func (dm *DagModifier) appendData(node *mdag.Node, spl chunk.Splitter) (*mdag.Node, error) {
dbp := &help.DagBuilderParams{ dbp := &help.DagBuilderParams{
Dagserv: dm.dagserv, Dagserv: dm.dagserv,
Maxlinks: help.DefaultLinksPerBlock, Maxlinks: help.DefaultLinksPerBlock,
} }
return trickle.TrickleAppend(dm.ctx, node, dbp.New(blks, errs)) return trickle.TrickleAppend(dm.ctx, node, dbp.New(spl))
} }
// Read data from this dag starting at the current offset // Read data from this dag starting at the current offset
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment