Skip to content

Commit

Permalink
feat(ref-imp): #781 - minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacJChen committed Sep 24, 2020
1 parent f71108c commit a0ba896
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/core/versions/latest/Delta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ErrorCode from './ErrorCode';
import ProtocolParameters from './ProtocolParameters';
import SidetreeError from '../../../common/SidetreeError';
import JsonCanonicalizer from './util/JsonCanonicalizer';

/**
* Class containing reusable operation delta functionalities.
Expand All @@ -9,6 +10,7 @@ export default class Delta {

/**
* Validates size of the encoded delta string.
* TODO: SIP 2 #781 delete this and use validateDeltaSize only
* @throws `SidetreeError` if fails validation.
*/
public static validateEncodedDeltaSize (encodedDelta: string) {
Expand All @@ -22,11 +24,9 @@ export default class Delta {

/**
* Validates size of the delta object
* TODO: SIP 2 #781 make observer check that the chunk file is cannonicalized, so we know that no filler characters are used
* Once we know there are no filler characters, it is valid to do size check on delta object because we know the object size === size in file
*/
public static validateDeltaSize (delta: object) {
const size = Buffer.byteLength(JSON.stringify(delta), 'utf8');
const size = Buffer.byteLength(JsonCanonicalizer.canonicalizeAsBuffer(delta));
if (size > ProtocolParameters.maxDeltaSizeInBytes) {
const errorMessage = `${size} bytes of 'delta' exceeded limit of ${ProtocolParameters.maxDeltaSizeInBytes} bytes.`;
console.info(errorMessage);
Expand Down
2 changes: 1 addition & 1 deletion lib/core/versions/latest/protocol-parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"maxNumberOfOperationsPerTransactionTime": 600000,
"maxNumberOfTransactionsPerTransactionTime": 300,
"maxOperationsPerBatch": 10000,
"maxDeltaSizeInBytes": 1000,
"maxDeltaSizeInBytes": 2000,
"maxNumberOfOperationsForNoValueTimeLock": 100,
"maxWriterLockIdInBytes": 200,
"normalizedFeeToPerOperationFeeMultiplier": 0.01,
Expand Down

0 comments on commit a0ba896

Please sign in to comment.