Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies January 2019 - Related to #2500 #2732

Merged
merged 17 commits into from Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.json
Expand Up @@ -16,13 +16,15 @@
}
],
"func-names": "off",
"implicit-arrow-linebreak": "off",
"max-len": "off",
"no-new": "off",
"no-param-reassign": "off",
"no-plusplus": "off",
"no-underscore-dangle": "off",
"no-unused-expressions": "off",
"no-use-before-define": "off",
"operator-linebreak": "off",
"prefer-destructuring": "off",
"radix": "off",
"require-jsdoc": [
Expand Down
7 changes: 4 additions & 3 deletions helpers/ed.js
Expand Up @@ -54,9 +54,9 @@ ed.makeKeypair = function(hash) {
* @todo Add description for the params and the return value
*/
ed.sign = function(hash, privateKey) {
if (!(hash instanceof Buffer))
if (!(hash instanceof Buffer)) {
throw new Error('argument message must be a buffer');

}
const signature = Buffer.alloc(sodium.crypto_sign_BYTES);
sodium.crypto_sign_detached(signature, hash, privateKey);

Expand All @@ -74,8 +74,9 @@ ed.sign = function(hash, privateKey) {
* @todo Add description for the params
*/
ed.verify = function(hash, signature, publicKey) {
if (!(hash instanceof Buffer) || !(signature instanceof Buffer))
if (!(hash instanceof Buffer) || !(signature instanceof Buffer)) {
throw new Error('argument message must be a buffer');
}
return sodium.crypto_sign_verify_detached(signature, hash, publicKey);
};

Expand Down
6 changes: 4 additions & 2 deletions helpers/json_history.js
Expand Up @@ -137,16 +137,18 @@ function JSONHistory(title, logger) {
}

assert(typeof json === 'object', 'Invalid json object to migrate.');
if (jsonVersion)
if (jsonVersion) {
assert(
semver.valid(jsonVersion),
'Invalid start version specified to migrate.'
);
if (migrateToVersion)
}
if (migrateToVersion) {
assert(
semver.valid(migrateToVersion),
'Invalid end version specified to migrate.'
);
}
assert(typeof cb === 'function', 'Invalid callback specified to migrate.');

self.logger.info(
Expand Down
9 changes: 6 additions & 3 deletions helpers/sort_by.js
Expand Up @@ -61,7 +61,8 @@ function sortBy(sort, options) {

if (keys.length === 0) {
return self.sortBy('');
} else if (keys.length === 1) {
}
if (keys.length === 1) {
return self.sortBy(
`${keys[0]}:${sort[keys[0]] === -1 ? 'desc' : 'asc'}`,
options
Expand Down Expand Up @@ -90,9 +91,11 @@ function sortBy(sort, options) {
function prefixField(prefixSortedField) {
if (!prefixSortedField) {
return prefixSortedField;
} else if (typeof options.fieldPrefix === 'string') {
}
if (typeof options.fieldPrefix === 'string') {
return options.fieldPrefix + prefixSortedField;
} else if (typeof options.fieldPrefix === 'function') {
}
if (typeof options.fieldPrefix === 'function') {
return options.fieldPrefix(prefixSortedField);
}
return prefixSortedField;
Expand Down
2 changes: 1 addition & 1 deletion logic/account.js
Expand Up @@ -495,6 +495,7 @@ class Account {
// Get field data type
const fieldType = self.conv[updatedField];
const updatedValue = diff[updatedField];
const value = new Bignum(updatedValue);

// Make execution selection based on field type
switch (fieldType) {
Expand All @@ -508,7 +509,6 @@ class Account {
// [u_]balance, [u_]multimin, [u_]multilifetime, fees, rewards, votes, producedBlocks, missedBlocks
// eslint-disable-next-line no-case-declarations
case Number:
const value = new Bignum(updatedValue);
if (value.isNaN() || !value.isFinite()) {
throw `Encountered insane number: ${value.toString()}`;
}
Expand Down
8 changes: 6 additions & 2 deletions logic/block_reward.js
Expand Up @@ -140,8 +140,12 @@ class BlockReward {
* @todo Add description for the params and the return value
*/
__private.parseHeight = function(height) {
if (Number.isNaN(height)) {
throw 'Invalid block height';
if (
typeof height === 'undefined' ||
height === null ||
Number.isNaN(height)
) {
throw new TypeError('Invalid block height');
} else {
return Math.abs(height);
}
Expand Down
3 changes: 2 additions & 1 deletion logic/broadcaster.js
Expand Up @@ -223,7 +223,8 @@ __private.filterQueue = function(cb) {
(broadcast, filterCb) => {
if (broadcast.options.immediate) {
return setImmediate(filterCb, null, false);
} else if (broadcast.options.data) {
}
if (broadcast.options.data) {
let transactionId;
if (broadcast.options.data.transaction) {
// Look for a transaction of a given "id" when broadcasting transactions
Expand Down
3 changes: 2 additions & 1 deletion logic/dapp.js
Expand Up @@ -201,7 +201,8 @@ DApp.prototype.verify = function(transaction, sender, cb, tx) {
cb,
`Application name already exists: ${dapp.name}`
);
} else if (dapp.link === transaction.asset.dapp.link) {
}
if (dapp.link === transaction.asset.dapp.link) {
return setImmediate(
cb,
`Application link already exists: ${dapp.link}`
Expand Down
6 changes: 4 additions & 2 deletions logic/transaction.js
Expand Up @@ -292,7 +292,8 @@ class Transaction {
return this.countById(transaction, (err, count) => {
if (err) {
return setImmediate(cb, err, false);
} else if (count > 0) {
}
if (count > 0) {
return setImmediate(cb, null, true);
}
return setImmediate(cb, null, false);
Expand Down Expand Up @@ -1128,7 +1129,8 @@ class Transaction {

if (!transactionType) {
return setImmediate(cb, `Unknown transaction type ${transaction.type}`);
} else if (typeof transactionType.afterSave === 'function') {
}
if (typeof transactionType.afterSave === 'function') {
return transactionType.afterSave.call(this, transaction, cb);
}
return setImmediate(cb);
Expand Down
3 changes: 2 additions & 1 deletion logic/transaction_pool.js
Expand Up @@ -997,7 +997,8 @@ __private.applyUnconfirmedList = function(transactions, cb, tx) {
__private.transactionTimeOut = function(transaction) {
if (transaction.type === transactionTypes.MULTI) {
return transaction.asset.multisignature.lifetime * self.hourInSeconds;
} else if (Array.isArray(transaction.signatures)) {
}
if (Array.isArray(transaction.signatures)) {
return UNCONFIRMED_TRANSACTION_TIMEOUT * 8;
}
return UNCONFIRMED_TRANSACTION_TIMEOUT;
Expand Down
38 changes: 20 additions & 18 deletions modules/blocks/process.js
Expand Up @@ -277,7 +277,8 @@ Process.prototype.getCommonBlock = function(peer, height, cb) {
if (err) {
modules.peers.remove(peer);
return setImmediate(waterCb, err);
} else if (!blocksCommonRes.common) {
}
if (!blocksCommonRes.common) {
// FIXME: Need better checking here, is base on 'common' property enough?
comparisonFailed = true;
return setImmediate(
Expand Down Expand Up @@ -666,13 +667,15 @@ Process.prototype.onReceiveBlock = function(block) {
) {
// Process received block
return __private.receiveBlock(block, cb);
} else if (
}
if (
block.previousBlock !== lastBlock.id &&
lastBlock.height + 1 === block.height
) {
// Process received fork cause 1
return __private.receiveForkOne(block, lastBlock, cb);
} else if (
}
if (
block.previousBlock === lastBlock.previousBlock &&
block.height === lastBlock.height &&
block.id !== lastBlock.id
Expand All @@ -682,22 +685,21 @@ Process.prototype.onReceiveBlock = function(block) {
}
if (block.id === lastBlock.id) {
library.logger.debug('Block already processed', block.id);
} else {
library.logger.warn(
[
'Discarded block that does not match with current chain:',
block.id,
'height:',
block.height,
'round:',
slots.calcRound(block.height),
'slot:',
slots.getSlotNumber(block.timestamp),
'generator:',
block.generatorPublicKey,
].join(' ')
);
}
library.logger.warn(
[
'Discarded block that does not match with current chain:',
block.id,
'height:',
block.height,
'round:',
slots.calcRound(block.height),
'slot:',
slots.getSlotNumber(block.timestamp),
'generator:',
block.generatorPublicKey,
].join(' ')
);

// Discard received block
return setImmediate(cb);
Expand Down
3 changes: 2 additions & 1 deletion modules/blocks/utils.js
Expand Up @@ -280,7 +280,8 @@ Utils.prototype.loadBlocksData = function(filter, cb, tx) {
// FIXME: filter.id is not used
if (filter.id && filter.lastId) {
return setImmediate(cb, 'Invalid filter: Received both id and lastId');
} else if (filter.id) {
}
if (filter.id) {
params.id = filter.id;
} else if (filter.lastId) {
params.lastId = filter.lastId;
Expand Down
3 changes: 2 additions & 1 deletion modules/blocks/verify.js
Expand Up @@ -796,7 +796,8 @@ Verify.prototype.processBlock = function(block, broadcast, saveBlock, cb) {
if (modules.blocks.isCleaning.get()) {
// Break processing if node shutdown reqested
return setImmediate(cb, 'Cleaning up');
} else if (!__private.loaded) {
}
if (!__private.loaded) {
// Break processing if blockchain is not loaded
return setImmediate(cb, 'Blockchain is loading');
}
Expand Down
6 changes: 4 additions & 2 deletions modules/transactions.js
Expand Up @@ -214,7 +214,8 @@ __private.list = function(filter, cb) {
fieldPrefix(sortField) {
if (['height'].indexOf(sortField) > -1) {
return `b_${sortField}`;
} else if (['confirmations'].indexOf(sortField) > -1) {
}
if (['confirmations'].indexOf(sortField) > -1) {
return sortField;
}
return `t_${sortField}`;
Expand Down Expand Up @@ -648,7 +649,8 @@ Transactions.prototype.applyUnconfirmed = function(

if (!sender && transaction.blockId !== library.genesisBlock.block.id) {
return setImmediate(cb, 'Invalid block id');
} else if (transaction.requesterPublicKey) {
}
if (transaction.requesterPublicKey) {
return modules.accounts.getAccount(
{ publicKey: transaction.requesterPublicKey },
(err, requester) => {
Expand Down
3 changes: 2 additions & 1 deletion modules/transport.js
Expand Up @@ -429,7 +429,8 @@ Transport.prototype.onBroadcastBlock = function(block, broadcast) {
'Transport->onBroadcastBlock: Aborted - max block relays exhausted'
);
return;
} else if (modules.loader.syncing()) {
}
if (modules.loader.syncing()) {
library.logger.debug(
'Transport->onBroadcastBlock: Aborted - blockchain synchronization in progress'
);
Expand Down