func (f *chunkFeeder) Sum() ([]byte, error) {
	// flush existing data in the buffer
	if f.bufferIdx > 0 {
		d := make([]byte, f.bufferIdx+span)
		copy(d[span:], f.buffer[:f.bufferIdx])
		binary.LittleEndian.PutUint64(d[:span], uint64(f.bufferIdx))
		args := &pipeline.PipeWriteArgs{Data: d, Span: d[:span]}
		err := f.next.ChainWrite(args)
		if err != nil {
			return nil, err
		}
		f.wrote += int64(len(d))
	}

	if f.wrote == 0 {
		// this is an empty file, we should write the span of
		// an empty file (0).
		d := make([]byte, span)
		args := &pipeline.PipeWriteArgs{Data: d, Span: d}
		err := f.next.ChainWrite(args)
		if err != nil {
			return nil, err
		}
		f.wrote += int64(len(d))
	}

	return f.next.Sum()
}
// Sum flushes any pending data to subsequent writers and returns
// the cryptographic root-hash respresenting the data written to
// the feeder.
Sum flushes any pending data to subsequent writers and returns
the cryptographic root-hash respresenting the data written to
the feeder.
// Sum flushes any pending data to subsequent writers and returns // the cryptographic root - hash respresenting the data written to // the feeder .
func (f *chunkFeeder) Sum() ([]byte, error) {
	if f.bufferIdx > 0 {
		d := make([]byte, f.bufferIdx+span)
		copy(d[span:], f.buffer[:f.bufferIdx])
		binary.LittleEndian.PutUint64(d[:span], uint64(f.bufferIdx))
		args := &pipeline.PipeWriteArgs{Data: d, Span: d[:span]}
		err := f.next.ChainWrite(args)
		if err != nil {
			return nil, err
		}
		f.wrote += int64(len(d))
	}
	if f.wrote == 0 {
		d := make([]byte, span)
		args := &pipeline.PipeWriteArgs{Data: d, Span: d}
		err := f.next.ChainWrite(args)
		if err != nil {
			return nil, err
		}
		f.wrote += int64(len(d))
	}
	return f.next.Sum()
}
func ( f * chunkFeeder ) Sum ( ) ( [ ] byte , error ) { if f . bufferIdx > 0 { d := make ( [ ] byte , f . bufferIdx + span ) copy ( d [ span : ] , f . buffer [ : f . bufferIdx ] ) binary . LittleEndian . PutUint64 ( d [ : span ] , uint64 ( f . bufferIdx ) ) args := & pipeline . PipeWriteArgs { Data : d , Span : d [ : span ] } err := f . next . ChainWrite ( args ) if err != nil { return nil , err } f . wrote += int64 ( len ( d ) ) } if f . wrote == 0 { d := make ( [ ] byte , span ) args := & pipeline . PipeWriteArgs { Data : d , Span : d } err := f . next . ChainWrite ( args ) if err != nil { return nil , err } f . wrote += int64 ( len ( d ) ) } return f . next . Sum ( ) }
Sum flushes any pending data to subsequent writers and returns
the cryptographic root-hash respresenting the data written to
the feeder.
Sum flushes any pending data to subsequent writers and returns the cryptographic root - hash respresenting the data written to the feeder .
// flush existing data in the buffer // this is an empty file, we should write the span of // an empty file (0).