func (rs *rsCode) Recover(pieces [][]byte, n uint64, w io.Writer) error {
	err := rs.enc.ReconstructData(pieces)
	if err != nil {
		return err
	}
	return rs.enc.Join(w, pieces, int(n))
}
Recover recovers the original data from pieces and writes it to w.
pieces should be identical to the slice returned by Encode (length and
order must be preserved), but with missing elements set to nil.
package renter
import (
	"fmt"
	"io"
	"github.com/klauspost/reedsolomon"
	"github.com/NebulousLabs/Sia/modules"
)
type rsCode struct {
	enc reedsolomon.Encoder
	numPieces  int
	dataPieces int
}
func (rs *rsCode) NumPieces() int { return rs.numPieces }
func (rs *rsCode) MinPieces() int { return rs.dataPieces }
func (rs *rsCode) Encode(data []byte) ([][]byte, error) {
	pieces, err := rs.enc.Split(data)
	if err != nil {
		return nil, err
	}
	err = rs.enc.Encode(pieces)
	if err != nil {
		return nil, err
	}
	return pieces, nil
}
func (rs *rsCode) EncodeShards(pieces [][]byte) ([][]byte, error) {
	if len(pieces) != rs.MinPieces() {
		return nil, fmt.Errorf("invalid number of pieces given %v %v", len(pieces), rs.MinPieces())
	}
	for len(pieces) < rs.NumPieces() {
		pieces = append(pieces, make([]byte, pieceSize))
	}
	err := rs.enc.Encode(pieces)
	if err != nil {
		return nil, err
	}
	return pieces, nil
}