()
| 559 | } |
| 560 | |
| 561 | func (d *Decoder) newCoderAndShards() (rsec16.Coder, [][]byte, error) { |
| 562 | if len(d.fileIntegrityInfos) == 0 { |
| 563 | return rsec16.Coder{}, nil, errors.New("no file integrity info") |
| 564 | } |
| 565 | |
| 566 | if len(d.parityShards) == 0 { |
| 567 | return rsec16.Coder{}, nil, errors.New("no parity shards") |
| 568 | } |
| 569 | |
| 570 | var dataShards [][]byte |
| 571 | for _, info := range d.fileIntegrityInfos { |
| 572 | for _, shardInfo := range info.shardInfos { |
| 573 | dataShards = append(dataShards, shardInfo.data) |
| 574 | } |
| 575 | } |
| 576 | coder, err := rsec16.NewCoderPAR2Vandermonde(len(dataShards), len(d.parityShards), d.numGoroutines) |
| 577 | if err != nil { |
| 578 | return rsec16.Coder{}, nil, err |
| 579 | } |
| 580 | |
| 581 | return coder, dataShards, err |
| 582 | } |
| 583 | |
| 584 | // ShardCounts contains shard counts which can be used to deduce |
| 585 | // whether repair is necessary and/or possible. |
no test coverage detected