diff --git a/pkg/encoding/erasure/cauchy_test.go b/pkg/encoding/erasure/cauchy_test.go index 0d1ef38c6..d577d97d3 100644 --- a/pkg/encoding/erasure/cauchy_test.go +++ b/pkg/encoding/erasure/cauchy_test.go @@ -29,8 +29,12 @@ var _ = Suite(&MySuite{}) func Test(t *testing.T) { TestingT(t) } +const ( + k = 10 + m = 5 +) + func (s *MySuite) TestCauchyDecode(c *C) { - const k, m = 10, 5 ep, _ := ParseEncoderParams(k, m, Cauchy) data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.") diff --git a/pkg/encoding/erasure/erasure_decode.go b/pkg/encoding/erasure/erasure_decode.go index 0d788cac1..a4de0fdf6 100644 --- a/pkg/encoding/erasure/erasure_decode.go +++ b/pkg/encoding/erasure/erasure_decode.go @@ -37,8 +37,8 @@ func (e *Encoder) Decode(chunks [][]byte, length int) ([]byte, error) { var decode_index *C.uint32_t var source, target **C.uint8_t - k := e.parms.K - m := e.parms.M + k := e.params.K + m := e.params.M n := k + m if len(chunks) != int(n) { return nil, errors.New(fmt.Sprintf("chunks length must be %d", n)) diff --git a/pkg/encoding/erasure/erasure_encode.go b/pkg/encoding/erasure/erasure_encode.go index c0cb39282..65f1313e1 100644 --- a/pkg/encoding/erasure/erasure_encode.go +++ b/pkg/encoding/erasure/erasure_encode.go @@ -51,7 +51,7 @@ type EncoderParams struct { // Encoder is an object used to encode and decode data. type Encoder struct { - parms *EncoderParams + params *EncoderParams encode_matrix, encode_tbls, decode_matrix, @@ -104,7 +104,7 @@ func NewEncoder(ep *EncoderParams) *Encoder { &encode_tbls) return &Encoder{ - parms: ep, + params: ep, encode_matrix: encode_matrix, encode_tbls: encode_tbls, decode_matrix: nil, @@ -134,11 +134,11 @@ func GetEncodedChunkLen(inputLen int, k uint8) (outputChunkLen int) { // length of the original object. func (e *Encoder) Encode(input []byte) ([][]byte, error) { inputLen := len(input) - k := C.int(e.parms.K) - m := C.int(e.parms.M) + k := C.int(e.params.K) + m := C.int(e.params.M) n := k + m - chunkLen := GetEncodedChunkLen(inputLen, e.parms.K) + chunkLen := GetEncodedChunkLen(inputLen, e.params.K) encodedDataLen := chunkLen * int(k) paddedDataLen := int(encodedDataLen) - inputLen @@ -148,7 +148,7 @@ func (e *Encoder) Encode(input []byte) ([][]byte, error) { input = append(input, s...) } - encodedParityLen := chunkLen * int(e.parms.M) + encodedParityLen := chunkLen * int(e.params.M) c := make([]byte, encodedParityLen) input = append(input, c...) diff --git a/pkg/encoding/erasure/vandermonde_test.go b/pkg/encoding/erasure/vandermonde_test.go index 5ed5ea309..853dd086f 100644 --- a/pkg/encoding/erasure/vandermonde_test.go +++ b/pkg/encoding/erasure/vandermonde_test.go @@ -23,7 +23,7 @@ import ( ) func (s *MySuite) TestVanderMondeDecode(c *C) { - ep, _ := ParseEncoderParams(10, 5, Vandermonde) + ep, _ := ParseEncoderParams(k, m, Vandermonde) data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")