Skip to content

Commit

Permalink
fix: Lint JS
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed Dec 22, 2023
1 parent e0b7cec commit 5f0cb31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-turkeys-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bnb-chain/reed-solomon': patch
---

fix: Lint Code
13 changes: 4 additions & 9 deletions packages/reed-solomon/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ export class ReedSolomon {

const dataLen = data.length;

const perShard = parseInt((dataLen + this.dataShards - 1) / this.dataShards);
// Calculate number of bytes per data shard.
const perShard = Math.floor((dataLen + this.dataShards - 1) / this.dataShards);
const needTotal = this.totalShards * perShard;

// console.log('dataLen', dataLen)
// console.log('needTotal', needTotal)
// console.log('perShard', perShard)

let tmp = Array.prototype.slice.call(data);
if (this.segmentSize > data.length) {
if (this.segmentSize > needTotal) {
Expand All @@ -66,12 +63,11 @@ export class ReedSolomon {

let padding = [];
if (data.length < needTotal) {
const fullShards = parseInt(data.length / perShard);
// padding = new Array(this.totalShards - fullShards).fill(0);
const fullShards = Math.floor(data.length / perShard);
padding = this._allocAligned(this.totalShards - fullShards, perShard);

if (dataLen > perShard * fullShards) {
const copyFrom = data.slice(perShard * fullShards, dataLen);
let copyFrom = data.slice(perShard * fullShards, dataLen);
for (let i = 0; i < padding.length; i++) {
if (copyFrom.length > 0) {
padding[i] = copyFrom.slice(0, perShard);
Expand Down Expand Up @@ -146,7 +142,6 @@ export class ReedSolomon {
parity,
shared.slice(0, this.dataShards),
output.slice(0, this.parityShards),
shared[0].length,
);
}

Expand Down

0 comments on commit 5f0cb31

Please sign in to comment.