Skip to content

Commit

Permalink
fix: SwapRows (#458)
Browse files Browse the repository at this point in the history
* fix: SwapRows

* feat: Assert params
  • Loading branch information
rrr523 authored Dec 29, 2023
1 parent d9e0b2f commit 4cf4abc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-camels-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bnb-chain/reed-solomon': patch
---

fix: SwapRows
3 changes: 0 additions & 3 deletions packages/reed-solomon/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ export class ReedSolomon {
};
}

/**
* @param {Array[{index, segChecksum, encodeDataHash}]} encodeShards
*/
getChecksumsByEncodeShards(encodeShards) {
let hashList = [];
let segChecksumList = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/reed-solomon/src/matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function gaussianElimination(m) {
if (m[r][r] === 0) {
for (let rowBelow = r + 1; rowBelow < rows; rowBelow++) {
if (m[rowBelow][r] !== 0) {
let err = SwapRows(r, rowBelow);
let err = SwapRows(m, r, rowBelow);
if (err !== null) {
return err;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/reed-solomon/src/web.adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export class WebAdapterReedSolomon extends ReedSolomon {
}

async encodeInWorker(sourceData) {
if (!this.workerNum || !this.workers)
throw new Error('`initWorkers` must be executed first to ensure the number of workers');

// RES is `encodeShards` Array
let RES = [];
const chunkList = splitPrice(sourceData, this.segmentSize);
Expand Down

0 comments on commit 4cf4abc

Please sign in to comment.