Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #144 from braydonf/max-shard-size
Browse files Browse the repository at this point in the history
Add max shard size
  • Loading branch information
aleitner committed Jan 3, 2018
2 parents 4dd6c81 + 4586a77 commit 52b6cd7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = {
OTHER: 'adjustment'
},
MIN_SHARD_SIZE: 15360,
MAX_SHARD_SIZE: 4294967296,
MAX_REPUTATION_POINTS: 5000,
MIN_REPUTATION_POINTS: 0,
POINTS: {
Expand Down
5 changes: 5 additions & 0 deletions lib/models/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ Frame.statics.validShardSizes = function(shards) {
return false;
}
}
for (let i = 0; i < shards.length; i++) {
if (shards[i].size > constants.MAX_SHARD_SIZE) {
return false;
}
}
}
return true;
};
Expand Down
28 changes: 28 additions & 0 deletions test/frame.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,34 @@ describe('Storage/models/Frame', function() {
expect(Frame.validShardSizes(shards)).to.equal(false);
});

it('it should reject max shard sizes', function() {
const shards = [
{
index: 0,
size: 4294967297
},
{
index: 1,
size: 4294967297
},
{
index: 2,
size: 30000
},
{
index: 3,
size: 4294967297,
parity: true
},
{
index: 4,
size: 4294967297,
parity: true
}
];
expect(Frame.validShardSizes(shards)).to.equal(false);
});

});

describe('#addShard', function() {
Expand Down

0 comments on commit 52b6cd7

Please sign in to comment.