diff --git a/.eslintrc b/.eslintrc index 5c8edccf218aed1f6f1447f25cf4885ad35962d7..9bab7d318bd79afd99277f8e5333f1da6b71a798 100644 --- a/.eslintrc +++ b/.eslintrc @@ -22,6 +22,7 @@ "no-trailing-spaces": 0, "no-unused-expressions": 0, "comma-spacing": 0, + "semi": 0, "quotes": [0, "double"], "linebreak-style": [1,"unix"], @@ -37,7 +38,6 @@ "no-unused-vars": [1], "space-infix-ops": [1], "handle-callback-err": [1], - "semi": [1,"always"], "no-extra-semi": [1] }, "env": { diff --git a/app/cli.js b/app/cli.js index 1ccaaded7a1ed70c1d710332308fa7f4d00de124..885ea413431ca6630145bdf9e0850d957bde7719 100644 --- a/app/cli.js +++ b/app/cli.js @@ -2,7 +2,6 @@ const co = require('co'); const logger = require('../app/lib/logger')('cli'); -const async = require('async'); const Q = require('q'); const _ = require('underscore'); const Command = require('commander').Command; @@ -10,7 +9,6 @@ const contacter = require('../app/lib/contacter'); const directory = require('../app/lib/system/directory'); const wizard = require('../app/lib/wizard'); const multicaster = require('../app/lib/streams/multicaster'); -const keyring = require('../app/lib/crypto/keyring'); const pjson = require('../package.json'); const duniter = require('../index'); const Peer = require('../app/lib/entity/peer'); @@ -94,8 +92,8 @@ module.exports = () => { const args = Array.from(arguments); return co(function*() { try { - const res = yield cmd.executionCallback.apply(null, [program].concat(args)); - onResolve(res); + const resOfExecution = yield cmd.executionCallback.apply(null, [program].concat(args)); + onResolve(resOfExecution); } catch (e) { onReject(e); } @@ -275,7 +273,7 @@ module.exports = () => { .command('reset [config|data|peers|tx|stats|all]') .description('Reset configuration, data, peers, transactions or everything in the database') .action(subCommand((type) => { - let init = ['data', 'all'].indexOf(type) !== -1 ? server.bind(server, program) : connect; + let init = ['data', 'all'].indexOf(type) !== -1 ? getServer.bind(getServer, program) : connect; return init(function (server) { if (!~['config', 'data', 'peers', 'stats', 'all'].indexOf(type)) { throw constants.ERRORS.CLI_CALLERR_RESET; @@ -335,12 +333,12 @@ module.exports = () => { function connect(callback, useDefaultConf) { return function () { - var cbArgs = arguments; - var dbName = program.mdb || "duniter_default"; - var dbHome = program.home; + const cbArgs = arguments; + const dbName = program.mdb || "duniter_default"; + const dbHome = program.home; const home = directory.getHome(dbName, dbHome); - var server = duniter(home, program.memory === true, commandLineConf(program)); + const theServer = duniter(home, program.memory === true, commandLineConf(program)); // If ever the process gets interrupted let isSaving = false; @@ -348,21 +346,21 @@ module.exports = () => { if (!isSaving) { isSaving = true; // Save DB - return server.disconnect(); + return theServer.disconnect(); } }); // Initialize server (db connection, ...) - return server.plugFileSystem(useDefaultConf) - .then(() => server.loadConf()) + return theServer.plugFileSystem(useDefaultConf) + .then(() => theServer.loadConf()) .then(function () { try { cbArgs.length--; - cbArgs[cbArgs.length++] = server; - cbArgs[cbArgs.length++] = server.conf; + cbArgs[cbArgs.length++] = theServer; + cbArgs[cbArgs.length++] = theServer.conf; return callback.apply(this, cbArgs); } catch(e) { - server.disconnect(); + theServer.disconnect(); throw e; } }); @@ -378,15 +376,15 @@ module.exports = () => { require('../app/lib/logger')().mute(); } - var cbArgs = arguments; - var dbName = program.mdb; - var dbHome = program.home; + const cbArgs = arguments; + const dbName = program.mdb; + const dbHome = program.home; // Add log files for this instance logger.addHomeLogs(directory.getHome(dbName, dbHome)); const home = directory.getHome(dbName, dbHome); - var server = duniter(home, program.memory === true, commandLineConf(program)); + const theServer = duniter(home, program.memory === true, commandLineConf(program)); // If ever the process gets interrupted let isSaving = false; @@ -394,7 +392,7 @@ module.exports = () => { if (!isSaving) { isSaving = true; // Save DB - return server.disconnect(); + return theServer.disconnect(); } }); @@ -403,17 +401,17 @@ module.exports = () => { // Initialize server (db connection, ...) return co(function*() { try { - yield server.initWithDAL(); - yield configure(program, server, server.conf || {}); - yield server.loadConf(); + yield theServer.initWithDAL(); + yield configure(program, theServer, theServer.conf || {}); + yield theServer.loadConf(); cbArgs.length--; - cbArgs[cbArgs.length++] = server; - cbArgs[cbArgs.length++] = server.conf; + cbArgs[cbArgs.length++] = theServer; + cbArgs[cbArgs.length++] = theServer.conf; cbArgs[cbArgs.length++] = program; - onService && onService(server); + onService && onService(theServer); return callback.apply(that, cbArgs); } catch (e) { - server.disconnect(); + theServer.disconnect(); throw e; } }); @@ -511,10 +509,9 @@ function commandLineConf(program, conf) { * Super basic server with only its home path set * @param program * @param callback - * @param useDefaultConf * @returns {Function} */ -function server(program, callback, useDefaultConf) { +function getServer(program, callback) { return function () { var cbArgs = arguments; var dbName = program.mdb || "duniter_default"; @@ -536,8 +533,8 @@ function parsePercent(s) { } function needsToBeLaunchedByScript() { - logger.error('This command must not be launched directly, using duniter.sh script'); - return Promise.resolve(); + logger.error('This command must not be launched directly, using duniter.sh script'); + return Promise.resolve(); } function configure(program, server, conf) { diff --git a/app/controllers/blockchain.js b/app/controllers/blockchain.js index e0a3e4a37bd6491e528c4118ff6b7435c4b5c4c7..b920b8c5c5de2326e88be7f8aa3546ae3af32821 100644 --- a/app/controllers/blockchain.js +++ b/app/controllers/blockchain.js @@ -2,7 +2,6 @@ const co = require('co'); const _ = require('underscore'); -const rules = require('../lib/rules'); const constants = require('../lib/constants'); const http2raw = require('../lib/helpers/http2raw'); const Membership = require('../lib/entity/membership'); diff --git a/app/controllers/network.js b/app/controllers/network.js index 328e084dfa28ae80a21d81e9ce5c65f654938e54..8aaf57fdf90478957860beb0fb2d8a2616dfde11 100644 --- a/app/controllers/network.js +++ b/app/controllers/network.js @@ -1,7 +1,6 @@ "use strict"; const _ = require('underscore'); const co = require('co'); -const Q = require('q'); const http2raw = require('../lib/helpers/http2raw'); const constants = require('../lib/constants'); const Peer = require('../lib/entity/peer'); diff --git a/app/controllers/transactions.js b/app/controllers/transactions.js index ed2e19ed0074cd18732574341545c0ac53981f00..b942455b6941cad05ddc95f381d412a19230ebee 100644 --- a/app/controllers/transactions.js +++ b/app/controllers/transactions.js @@ -78,7 +78,7 @@ function TransactionBinding(server) { }); }); - this.getPending = (req) => co(function *() { + this.getPending = () => co(function *() { const pending = yield server.dal.getTransactionsPending(); const res = { "currency": conf.currency, @@ -91,19 +91,19 @@ function TransactionBinding(server) { }); const getFilteredHistory = (pubkey, filter) => co(function*() { - let history = yield server.dal.getTransactionsHistory(pubkey); - let result = { - "currency": conf.currency, - "pubkey": pubkey, - "history": history - }; - _.keys(history).map((key) => { - history[key].map((tx, index) => { - history[key][index] = _.omit(new Transaction(tx).json(), 'currency', 'raw'); - _.extend(history[key][index], {block_number: tx && tx.block_number, time: tx && tx.time}); - }); + let history = yield server.dal.getTransactionsHistory(pubkey); + let result = { + "currency": conf.currency, + "pubkey": pubkey, + "history": history + }; + _.keys(history).map((key) => { + history[key].map((tx, index) => { + history[key][index] = _.omit(new Transaction(tx).json(), 'currency', 'raw'); + _.extend(history[key][index], {block_number: tx && tx.block_number, time: tx && tx.time}); }); - return filter(result); + }); + return filter(result); }); return this; diff --git a/app/controllers/uds.js b/app/controllers/uds.js index 6afeabace3c9ad74cb98e6715fc3210ec573229b..b8c4378baec35a0a4b89beb3c5f78ae642b99431 100644 --- a/app/controllers/uds.js +++ b/app/controllers/uds.js @@ -1,6 +1,5 @@ "use strict"; const co = require('co'); -const Q = require('q'); const _ = require('underscore'); module.exports = function (server) { diff --git a/app/controllers/wot.js b/app/controllers/wot.js index fb8979a7a641e66dadedc14a8d6cc06e14d5c434..6a7d653cd0f5e43832175c0eccdfbbd28f7064b7 100644 --- a/app/controllers/wot.js +++ b/app/controllers/wot.js @@ -220,7 +220,7 @@ function WOTBinding (server) { this.revoke = (req) => this.pushEntity(req, http2raw.revocation, constants.ENTITY_REVOCATION); - this.pendingMemberships = (req) => co(function*() { + this.pendingMemberships = () => co(function*() { const memberships = yield server.dal.findNewcomers(); const json = { memberships: [] diff --git a/app/lib/cfs.js b/app/lib/cfs.js index a6eab9a600bd88aa0e537da9e677eaf3e2f32155..e1821e79fca96849e45bf1f91e37e74d3312c1d3 100644 --- a/app/lib/cfs.js +++ b/app/lib/cfs.js @@ -1,6 +1,5 @@ "use strict"; -const Q = require('q'); const _ = require('underscore'); const co = require('co'); const path = require('path'); @@ -24,7 +23,7 @@ function CFSCore(rootPath, qfs, parent) { /** * Creates the deletion folder before effective deletion. - * @returns {*|any|Q.Promise<void>} Promise of creation. + * @returns {*|any|Promise<void>} Promise of creation. */ const createDeletionFolder = () => deletionFolderPromise || (deletionFolderPromise = that.makeTree('.deleted')); diff --git a/app/lib/computation/blockGenerator.js b/app/lib/computation/blockGenerator.js index e3194aa1d2ea3a98a7e74aeb91ae8964da209d39..7922bd59f39d4d9830e05f19d7a0e902fdf77b6f 100644 --- a/app/lib/computation/blockGenerator.js +++ b/app/lib/computation/blockGenerator.js @@ -23,12 +23,11 @@ module.exports = (mainContext, prover) => { function BlockGenerator(mainContext, prover) { const that = this; - let conf, dal, keyPair, selfPubkey, logger; + let conf, dal, selfPubkey, logger; this.setConfDAL = (newConf, newDAL, newKeyPair) => { dal = newDAL; conf = newConf; - keyPair = newKeyPair; selfPubkey = newKeyPair.publicKey; logger = require('../logger')(dal.profile); }; @@ -435,7 +434,7 @@ function BlockGenerator(mainContext, prover) { block.medianTime = vHEAD.medianTime; } // Choose the version - block.version = (manualValues && manualValues.version) || (yield rules.HELPERS.getMaxPossibleVersionNumber(current, block)); + block.version = (manualValues && manualValues.version) || (yield rules.HELPERS.getMaxPossibleVersionNumber(current)); block.currency = current ? current.currency : conf.currency; block.nonce = 0; block.parameters = block.number > 0 ? '' : [ diff --git a/app/lib/computation/blockProver.js b/app/lib/computation/blockProver.js index bb66e2e2813fc8a78b09030cc79f3b880a8ef095..96f17ff433c75240f0583e03bcd67ed4c4a3fcbb 100644 --- a/app/lib/computation/blockProver.js +++ b/app/lib/computation/blockProver.js @@ -3,7 +3,6 @@ const co = require('co'); const _ = require('underscore'); const constants = require('../constants'); const engine = require('../pow/engine'); -const path = require('path'); const Block = require('../entity/block'); const querablep = require('../querablep'); @@ -14,7 +13,7 @@ module.exports = (server) => new BlockGenerator(server); function BlockGenerator(notifier) { - let conf, pair, logger, wait = null, waitResolve; + let conf, pair, logger, waitResolve; let workerFarmPromise; @@ -36,10 +35,6 @@ function BlockGenerator(notifier) { process.execArgv = []; } - this.waitForNewAsking = () => wait = new Promise((resolve) => { - waitResolve = resolve; - }); - this.cancel = (gottenBlock) => co(function*() { // If no farm was instanciated, tehre is nothing to do yet if (workerFarmPromise) { @@ -50,7 +45,6 @@ function BlockGenerator(notifier) { if (waitResolve) { waitResolve(); waitResolve = null; - wait = null; } } }); @@ -60,7 +54,6 @@ function BlockGenerator(notifier) { if (waitResolve) { waitResolve(); waitResolve = null; - wait = null; } const remainder = difficulty % 16; diff --git a/app/lib/computation/blockchainContext.js b/app/lib/computation/blockchainContext.js index dbc66ec86dd47b8f208de9376888eda05ee766de..54d31fb873cae1776382d1420e9378cbdbcbdfdc 100644 --- a/app/lib/computation/blockchainContext.js +++ b/app/lib/computation/blockchainContext.js @@ -3,8 +3,6 @@ const _ = require('underscore'); const co = require('co'); const Q = require('q'); const indexer = require('../dup/indexer'); -const hashf = require('../ucp/hashf'); -const rawer = require('../ucp/rawer'); const constants = require('../constants'); const rules = require('../rules/index'); const Identity = require('../entity/identity'); @@ -263,9 +261,7 @@ function BlockchainContext() { } const block = forks[0]; yield that.checkBlock(block, constants.WITH_SIGNATURES_AND_POW); - const res = yield that.addBlock(block); logger.debug('Applied block #%s', block.number); - // return res; }); this.revertBlock = (block) => co(function *() { @@ -383,7 +379,7 @@ function BlockchainContext() { // Delete eventually present transactions yield that.deleteTransactions(block); - yield dal.trimSandboxes(block, conf); + yield dal.trimSandboxes(block); return block; }); @@ -455,7 +451,7 @@ function BlockchainContext() { dal.wotb.setEnabled(false, idty.wotb_id); } // Undo newcomers - for (const identity of block.identities) { + for (let i = 0; i < block.identities.length; i++) { // Does not matter which one it really was, we pop the last X identities dal.wotb.removeNode(); } diff --git a/app/lib/computation/permanentProver.js b/app/lib/computation/permanentProver.js index 536c5153663ac519cc46f001ced8d89cb3d6ebc1..d2de48569bf24ef7cd0a2f93f1f2cc907c779209 100644 --- a/app/lib/computation/permanentProver.js +++ b/app/lib/computation/permanentProver.js @@ -2,8 +2,6 @@ const co = require('co'); const constants = require('../constants'); -const rules = require('../rules'); -const parsers = require('../streams/parsers'); module.exports = (server) => new PermanentProver(server); @@ -49,7 +47,7 @@ function PermanentProver(server) { if (!selfPubkey) { throw 'No self pubkey found.'; } - let block, current; + let current; const isMember = yield dal.isMember(selfPubkey); if (!isMember) { throw 'Local node is not a member. Waiting to be a member before computing a block.'; diff --git a/app/lib/crypto/base58.js b/app/lib/crypto/base58.js index 3b88f9d489222d48bb82e9400b9ff15fe3d3bade..acfeef7d038e601fdda6719077b1bf9f954bd664 100644 --- a/app/lib/crypto/base58.js +++ b/app/lib/crypto/base58.js @@ -75,4 +75,4 @@ Base58.decode = function(string) { return (new Uint8Array(bytes)) } -module.exports = Base58; \ No newline at end of file +module.exports = Base58; diff --git a/app/lib/dal/drivers/sqlite.js b/app/lib/dal/drivers/sqlite.js index 2aaccbb58543ed936c2e3504bfc56408487412ef..107004f80e594c35be2e767cfad9532ef33c3c80 100644 --- a/app/lib/dal/drivers/sqlite.js +++ b/app/lib/dal/drivers/sqlite.js @@ -19,11 +19,11 @@ function SQLiteDriver(path) { function getDB() { return dbPromise || (dbPromise = co(function*() { - logger.debug('Opening SQLite database "%s"...', path); - let sqlite = new sqlite3.Database(path); - yield new Promise((resolve) => sqlite.once('open', resolve)); - // Database is opened and ready - return sqlite; + logger.debug('Opening SQLite database "%s"...', path); + let sqlite = new sqlite3.Database(path); + yield new Promise((resolve) => sqlite.once('open', resolve)); + // Database is opened and ready + return sqlite; })); } @@ -88,4 +88,4 @@ function SQLiteDriver(path) { } }); }); -} \ No newline at end of file +} diff --git a/app/lib/dal/fileDAL.js b/app/lib/dal/fileDAL.js index 164415e88a1c63caf35d690bd68c0be2d7fe3aeb..65158fc5222a6928d9404add7f4e7859f1c99ef2 100644 --- a/app/lib/dal/fileDAL.js +++ b/app/lib/dal/fileDAL.js @@ -3,10 +3,7 @@ const Q = require('q'); const co = require('co'); const _ = require('underscore'); const indexer = require('../dup/indexer'); -const hashf = require('../ucp/hashf'); -const wotb = require('../wot'); const logger = require('../logger')('filedal'); -const directory = require('../system/directory'); const Configuration = require('../entity/configuration'); const Merkle = require('../entity/merkle'); const Transaction = require('../entity/transaction'); @@ -62,8 +59,6 @@ function FileDAL(params) { 'cindexDAL': that.cindexDAL }; - let currency = ''; - this.init = () => co(function *() { const dalNames = _.keys(that.newDals); for (const dalName of dalNames) { @@ -300,14 +295,14 @@ function FileDAL(params) { let matching = certs; links.map((entry) => { entry.from = entry.issuer; - const co = entry.created_on.split('-'); - const wo = entry.written_on.split('-'); - entry.block = parseInt(co[0]); - entry.block_number = parseInt(co[0]); - entry.block_hash = co[1]; + const cbt = entry.created_on.split('-'); + const wbt = entry.written_on.split('-'); + entry.block = parseInt(cbt[0]); + entry.block_number = parseInt(cbt[0]); + entry.block_hash = cbt[1]; entry.linked = true; - entry.written_block = parseInt(wo[0]); - entry.written_hash = wo[1]; + entry.written_block = parseInt(wbt[0]); + entry.written_hash = wbt[1]; matching.push(entry); }); matching = _.sortBy(matching, (c) => -c.block); @@ -323,15 +318,15 @@ function FileDAL(params) { const idty = yield that.getWrittenIdtyByPubkey(entry.receiver); entry.from = entry.issuer; entry.to = entry.receiver; - const co = entry.created_on.split('-'); - const wo = entry.written_on.split('-'); - entry.block = parseInt(co[0]); - entry.block_number = parseInt(co[0]); - entry.block_hash = co[1]; + const cbt = entry.created_on.split('-'); + const wbt = entry.written_on.split('-'); + entry.block = parseInt(cbt[0]); + entry.block_number = parseInt(cbt[0]); + entry.block_hash = cbt[1]; entry.target = idty.hash; entry.linked = true; - entry.written_block = parseInt(wo[0]); - entry.written_hash = wo[1]; + entry.written_block = parseInt(wbt[0]); + entry.written_hash = wbt[1]; matching.push(entry); })); matching = _.sortBy(matching, (c) => -c.block); @@ -452,7 +447,7 @@ function FileDAL(params) { .indexOf(p.status) !== -1).value(); }); - this.listAllPeersWithStatusNewUPWithtout = (pubkey) => co(function *() { + this.listAllPeersWithStatusNewUPWithtout = () => co(function *() { const peers = yield that.peerDAL.listAll(); return _.chain(peers).filter((p) => p.status == 'UP').filter((p) => p.pubkey); }); @@ -506,7 +501,7 @@ function FileDAL(params) { this.saveBlock = (block) => co(function*() { block.wrong = false; yield [ - that.saveBlockInFile(block, true), + that.saveBlockInFile(block), that.saveTxsInFiles(block.transactions, {block_number: block.number, time: block.medianTime, currency: block.currency }) ]; }); @@ -552,7 +547,7 @@ function FileDAL(params) { return true; }); - this.trimSandboxes = (block, conf) => co(function*() { + this.trimSandboxes = (block) => co(function*() { yield that.certDAL.trimExpiredCerts(block.medianTime); yield that.msDAL.trimExpiredMemberships(block.medianTime); yield that.idtyDAL.trimExpiredIdentities(block.medianTime); @@ -561,7 +556,7 @@ function FileDAL(params) { this.savePendingMembership = (ms) => that.msDAL.savePendingMembership(ms); - this.saveBlockInFile = (block, check) => co(function *() { + this.saveBlockInFile = (block) => co(function *() { yield that.writeFileOfBlock(block); }); @@ -680,8 +675,6 @@ function FileDAL(params) { const savedConf = yield that.confDAL.loadConf(); conf = _(savedConf).extend(overrideConf || {}); } - // TODO: Do something about the currency global variable - currency = conf.currency; if (that.loadConfHook) { yield that.loadConfHook(conf); } @@ -690,8 +683,6 @@ function FileDAL(params) { this.saveConf = (confToSave) => { return co(function*() { - // TODO: Do something about the currency global variable - currency = confToSave.currency; // Save the conf in file let theConf = confToSave; if (that.saveConfHook) { diff --git a/app/lib/dal/sqliteDAL/AbstractIndex.js b/app/lib/dal/sqliteDAL/AbstractIndex.js index 4bfce7b82b58cfec2ae2fc89414380b04904e08c..c4f00a27f836aebe46d6c4646f8b4e958ba36ac7 100644 --- a/app/lib/dal/sqliteDAL/AbstractIndex.js +++ b/app/lib/dal/sqliteDAL/AbstractIndex.js @@ -33,4 +33,4 @@ function AbstractIndex() { } } }); -} \ No newline at end of file +} diff --git a/app/lib/dal/sqliteDAL/AbstractSQLite.js b/app/lib/dal/sqliteDAL/AbstractSQLite.js index cf2ea2f65ec2ae4af071861f65d9fffe35ee15c7..2551ce2ea1a894220bdcf6dece97f946217071aa 100644 --- a/app/lib/dal/sqliteDAL/AbstractSQLite.js +++ b/app/lib/dal/sqliteDAL/AbstractSQLite.js @@ -284,4 +284,4 @@ function AbstractSQLite(driver) { } return row; } -} \ No newline at end of file +} diff --git a/app/lib/dal/sqliteDAL/CertDAL.js b/app/lib/dal/sqliteDAL/CertDAL.js index 195168476162e7001f00c60bc0e05582e53b372d..a6959ed708195f794a740c767d0674541921634b 100644 --- a/app/lib/dal/sqliteDAL/CertDAL.js +++ b/app/lib/dal/sqliteDAL/CertDAL.js @@ -111,4 +111,4 @@ function CertDAL(driver) { this.getSandboxRoom = () => this.sandbox.getSandboxRoom(); this.setSandboxSize = (maxSize) => this.sandbox.maxSize = maxSize; -} \ No newline at end of file +} diff --git a/app/lib/dal/sqliteDAL/IdentityDAL.js b/app/lib/dal/sqliteDAL/IdentityDAL.js index 8befe1751ad1aa259ae46e77d669ee6f1338b9c0..11d273675b7dfbe7aa116e140319a76dac89e7aa 100644 --- a/app/lib/dal/sqliteDAL/IdentityDAL.js +++ b/app/lib/dal/sqliteDAL/IdentityDAL.js @@ -2,9 +2,7 @@ * Created by cgeek on 22/08/15. */ -const Q = require('q'); const co = require('co'); -const logger = require('../../logger')('idtyDAL'); const constants = require('../../constants'); const AbstractSQLite = require('./AbstractSQLite'); const SandBox = require('./SandBox'); diff --git a/app/lib/dal/sqliteDAL/MembershipDAL.js b/app/lib/dal/sqliteDAL/MembershipDAL.js index d4338a4ce89ce1fa85debd2b3456f1546c8b7119..e3f5564a7f56facd7b4d92be66dc830934994c50 100644 --- a/app/lib/dal/sqliteDAL/MembershipDAL.js +++ b/app/lib/dal/sqliteDAL/MembershipDAL.js @@ -2,7 +2,6 @@ * Created by cgeek on 22/08/15. */ -const Q = require('q'); const co = require('co'); const _ = require('underscore'); const AbstractSQLite = require('./AbstractSQLite'); diff --git a/app/lib/dal/sqliteDAL/MetaDAL.js b/app/lib/dal/sqliteDAL/MetaDAL.js index 79b6b1ecb32d0ad5f4d07c0dec93e33a13e7ed8d..69244c74b480a3a6909ae60fcd3e0b23bd513625 100644 --- a/app/lib/dal/sqliteDAL/MetaDAL.js +++ b/app/lib/dal/sqliteDAL/MetaDAL.js @@ -5,7 +5,6 @@ */ const co = require('co'); -const _ = require('underscore'); const logger = require('../../logger')('metaDAL'); const AbstractSQLite = require('./AbstractSQLite'); diff --git a/app/lib/dal/sqliteDAL/SandBox.js b/app/lib/dal/sqliteDAL/SandBox.js index e452310a348976dac7abbd39de533f23d7a2819d..4e7d836ee66dcbba0906831cb14cd7bbf6d3afbf 100644 --- a/app/lib/dal/sqliteDAL/SandBox.js +++ b/app/lib/dal/sqliteDAL/SandBox.js @@ -1,8 +1,6 @@ "use strict"; const co = require('co'); -const colors = require('colors'); -const logger = require('../../logger')('sqlite'); module.exports = SandBox; @@ -24,8 +22,8 @@ function SandBox(maxSize, findElements, compareElements) { return comparison > 0; }); - this.getSandboxRoom = (underBlock) => co(function *() { + this.getSandboxRoom = () => co(function *() { const elems = yield findElements(); return that.maxSize - elems.length; }); -} \ No newline at end of file +} diff --git a/app/lib/dal/sqliteDAL/index/BIndexDAL.js b/app/lib/dal/sqliteDAL/index/BIndexDAL.js index dfc2cb3b03c7bd3a0b6c3caa19e777b723f52226..9d5b80b743e6116c2a953cbda6ec787fe3892be3 100644 --- a/app/lib/dal/sqliteDAL/index/BIndexDAL.js +++ b/app/lib/dal/sqliteDAL/index/BIndexDAL.js @@ -3,7 +3,6 @@ */ const co = require('co'); -const _ = require('underscore'); const AbstractSQLite = require('./../AbstractSQLite'); module.exports = BIndexDAL; diff --git a/app/lib/dal/sqliteDAL/index/SIndexDAL.js b/app/lib/dal/sqliteDAL/index/SIndexDAL.js index c6fce27cb381531c0a153494861ee1b79e2b12db..d1b3ea817b1426b788a4f6357ec151a655bc1e1c 100644 --- a/app/lib/dal/sqliteDAL/index/SIndexDAL.js +++ b/app/lib/dal/sqliteDAL/index/SIndexDAL.js @@ -99,8 +99,8 @@ function SIndexDAL(driver) { }); this.findLowerThan = (amount, base) => co(function*() { - const baseConditions = Array.from({ length: (base +1) }).map((el, index) => { - return '(base = ' + index + ' and amount < ' + (amount*Math.pow(10, base - index)) + ')'; + const baseConditions = Array.from({ length: (base + 1) }).map((el, index) => { + return '(base = ' + index + ' and amount < ' + (amount * Math.pow(10, base - index)) + ')'; }).join(' OR '); const potentials = yield that.query('SELECT * FROM ' + that.table + ' s1 ' + 'WHERE s1.op = ? ' + diff --git a/app/lib/dup/indexer.js b/app/lib/dup/indexer.js index 2ce31dfdcc20f309f149feab35ec8a657976174d..2e02354893fdd3305856b457df608aa071ddd99a 100644 --- a/app/lib/dup/indexer.js +++ b/app/lib/dup/indexer.js @@ -468,8 +468,8 @@ const indexer = module.exports = { const ratio = constants.POW_DIFFICULTY_RANGE_RATIO; const maxGenTime = Math.ceil(conf.avgGenTime * ratio); const minGenTime = Math.floor(conf.avgGenTime / ratio); - const minSpeed = 1/ maxGenTime; - const maxSpeed = 1/ minGenTime; + const minSpeed = 1 / maxGenTime; + const maxSpeed = 1 / minGenTime; if (HEAD.diffNumber != HEAD_1.diffNumber && HEAD.speed >= maxSpeed && (HEAD_1.powMin + 2) % 16 == 0) { HEAD.powMin = HEAD_1.powMin + 2; @@ -784,11 +784,11 @@ const indexer = module.exports = { } else { const issuersVar = (HEAD.issuersCount - HEAD_1.issuersCount); if (HEAD_1.issuersFrameVar > 0) { - HEAD.issuersFrameVar = HEAD_1.issuersFrameVar + 5*issuersVar - 1; + HEAD.issuersFrameVar = HEAD_1.issuersFrameVar + 5 * issuersVar - 1; } else if (HEAD_1.issuersFrameVar < 0) { - HEAD.issuersFrameVar = HEAD_1.issuersFrameVar + 5*issuersVar + 1; + HEAD.issuersFrameVar = HEAD_1.issuersFrameVar + 5 * issuersVar + 1; } else { - HEAD.issuersFrameVar = HEAD_1.issuersFrameVar + 5*issuersVar; + HEAD.issuersFrameVar = HEAD_1.issuersFrameVar + 5 * issuersVar; } } }, diff --git a/app/lib/entity/block.js b/app/lib/entity/block.js index 743c16206a87df5fcbd69de29108d2b63793f337..d25478df7d93f535fb171e7e8275be324f23c191 100644 --- a/app/lib/entity/block.js +++ b/app/lib/entity/block.js @@ -1,6 +1,5 @@ "use strict"; const _ = require('underscore'); -const constants = require('../constants'); const hashf = require('../ucp/hashf'); const Transaction = require('./transaction'); @@ -69,8 +68,8 @@ function Block(json) { "issuersFrameVar", "len" ].forEach((field) => { - json[field] = parseInt(this[field], 10); - }); + json[field] = parseInt(this[field], 10); + }); [ "currency", "issuer", @@ -78,20 +77,20 @@ function Block(json) { "hash", "parameters" ].forEach((field) => { - json[field] = this[field] || ""; - }); + json[field] = this[field] || ""; + }); [ "previousHash", "previousIssuer", "inner_hash" ].forEach((field) => { - json[field] = this[field] || null; - }); + json[field] = this[field] || null; + }); [ "dividend" ].forEach((field) => { - json[field] = parseInt(this[field]) || null; - }); + json[field] = parseInt(this[field]) || null; + }); [ "identities", "joiners", @@ -101,19 +100,19 @@ function Block(json) { "excluded", "certifications" ].forEach((field) => { - json[field] = []; - this[field].forEach((raw) => { - json[field].push(raw); - }); + json[field] = []; + this[field].forEach((raw) => { + json[field].push(raw); }); + }); [ "transactions" ].forEach((field) => { - json[field] = []; - this[field].forEach((obj) => { - json[field].push(_(obj).omit('raw', 'certifiers', 'hash')); - }); + json[field] = []; + this[field].forEach((obj) => { + json[field].push(_(obj).omit('raw', 'certifiers', 'hash')); }); + }); json.raw = this.getRaw(); return json; }; diff --git a/app/lib/entity/certification.js b/app/lib/entity/certification.js index 7f1d5776f5f663273ce096f29687ea96cc868fe6..d724ce91acc1fa84685f422678659ebf5ead7573 100644 --- a/app/lib/entity/certification.js +++ b/app/lib/entity/certification.js @@ -8,7 +8,7 @@ const Certification = function(json) { this.linked = false; _(json).keys().forEach((key) => { - this[key] = json[key]; + this[key] = json[key]; }); this.from = this.pubkey = this.from || this.pubkey || this.issuer; diff --git a/app/lib/entity/peer.js b/app/lib/entity/peer.js index 4be05dd88aba57ab3f086742ce05237f17e82359..b54e4563bd26be4a903a0763ca67a256285e6183 100644 --- a/app/lib/entity/peer.js +++ b/app/lib/entity/peer.js @@ -1,5 +1,4 @@ "use strict"; -const Q = require('q'); const _ = require('underscore'); const contacter = require('../contacter'); const rawer = require('../ucp/rawer'); @@ -14,7 +13,7 @@ function Peer(json) { this.documentType = 'peer'; _(json).keys().forEach((key) => { - this[key] = json[key]; + this[key] = json[key]; }); this.endpoints = this.endpoints || []; diff --git a/app/lib/entity/revocation.js b/app/lib/entity/revocation.js index 8187a624b18d0a2aadce3e2e8245beb17c1bd9d5..e3c54fed10dcd64ec23ebc8329d9a5419f9f2cf0 100644 --- a/app/lib/entity/revocation.js +++ b/app/lib/entity/revocation.js @@ -1,13 +1,12 @@ "use strict"; const _ = require('underscore'); const rawer = require('../ucp/rawer'); -const ucp = require('../ucp/buid'); const Identity = require('./identity'); const Revocation = function(json) { _(json).keys().forEach((key) => { - this[key] = json[key]; + this[key] = json[key]; }); this.getRaw = () => rawer.getOfficialRevocation(this); diff --git a/app/lib/entity/source.js b/app/lib/entity/source.js index a903563aca3432c74c3f850af77c9717be41e6b8..05b6fcf452c7e6d51effb8900c7de49376050b14 100644 --- a/app/lib/entity/source.js +++ b/app/lib/entity/source.js @@ -35,4 +35,4 @@ function Source(json) { "base": this.base }; }; -} \ No newline at end of file +} diff --git a/app/lib/entity/stat.js b/app/lib/entity/stat.js index 09e9f53307a357ce8487d497d48b5d815074a0b6..1b459dbd90d1be15bc1a7ecf43e80daba0e8001e 100644 --- a/app/lib/entity/stat.js +++ b/app/lib/entity/stat.js @@ -3,7 +3,7 @@ const _ = require('underscore'); const Stat = function(json) { _(json).keys().forEach((key) => { - this[key] = json[key]; + this[key] = json[key]; }); this.json = function () { diff --git a/app/lib/entity/transaction.js b/app/lib/entity/transaction.js index 868e4addbb9c2dd0467edb749a8968b111890c29..32458ec4d30eadd452b495a9dbadcec3499e556d 100644 --- a/app/lib/entity/transaction.js +++ b/app/lib/entity/transaction.js @@ -2,7 +2,6 @@ let _ = require('underscore'); let rawer = require('../ucp/rawer'); let hashf = require('../ucp/hashf'); -let constants = require('../constants'); let Transaction = function(obj, currency) { @@ -15,7 +14,7 @@ let Transaction = function(obj, currency) { this.issuers = []; _(json).keys().forEach((key) => { - this[key] = json[key]; + this[key] = json[key]; }); // Store the maximum output base diff --git a/app/lib/logger/index.js b/app/lib/logger/index.js index 5c149af281e894a24e4857ca05873d60c3374578..81f9e37daa9383a69485b924f7dd278303fbc9f9 100644 --- a/app/lib/logger/index.js +++ b/app/lib/logger/index.js @@ -3,7 +3,6 @@ const moment = require('moment'); const path = require('path'); const winston = require('winston'); const cbLogger = require('./callbackLogger'); -const directory = require('../system/directory'); const customLevels = { levels: { diff --git a/app/lib/pow/engine.js b/app/lib/pow/engine.js index 07674f03fef060ad5a19310a264d0e83aed3c6c8..c2f9416fdec2bdfe0bf17132ecdc713bb659dac8 100644 --- a/app/lib/pow/engine.js +++ b/app/lib/pow/engine.js @@ -96,4 +96,4 @@ function PowEngine() { this.isConnected = () => powProcess ? powProcess.connected : false; this.setOnInfoMessage = (callback) => onInfoMessage = callback; -} \ No newline at end of file +} diff --git a/app/lib/rules/global_rules.js b/app/lib/rules/global_rules.js index e837eb2ae232fc2ecaa3eefdc2844bb04d813de0..a067bdd6cc728500965c7accd88ac3b0972d06c0 100644 --- a/app/lib/rules/global_rules.js +++ b/app/lib/rules/global_rules.js @@ -8,8 +8,6 @@ const keyring = require('../crypto/keyring'); const rawer = require('../ucp/rawer'); const indexer = require('../dup/indexer'); const Identity = require('../entity/identity'); -const Membership = require('../entity/membership'); -const Certification = require('../entity/certification'); const Transaction = require('../entity/transaction'); const logger = require('../logger')('globr'); const unlock = require('../ucp/txunlock'); diff --git a/app/lib/rules/index.js b/app/lib/rules/index.js index ff8e25af4009e2f17f1a9cd407525357cc4133a5..284ce198aecd0b7aa7d4fdff858db41584b3e245 100644 --- a/app/lib/rules/index.js +++ b/app/lib/rules/index.js @@ -78,7 +78,7 @@ rules.ALIAS = { rules.CHECK = { ASYNC: { ALL_LOCAL: checkLocal(rules.ALIAS.ALL_LOCAL), - ALL_LOCAL_BUT_POW: checkLocal(rules.ALIAS.ALL_LOCAL_BUT_POW_AND_SIGNATURE), + ALL_LOCAL_BUT_POW: checkLocal(rules.ALIAS.ALL_LOCAL_BUT_POW_AND_SIGNATURE) } }; diff --git a/app/lib/rules/local_rules.js b/app/lib/rules/local_rules.js index c7f4d95d7920f4930f3368bf868b8294b6f30df0..b713db8550c40096b0edcfcbe6fab299ed8cb250 100644 --- a/app/lib/rules/local_rules.js +++ b/app/lib/rules/local_rules.js @@ -143,7 +143,7 @@ rules.FUNCTIONS = { .pluck('pub') .value(); for (const pub of revocations) { - const exclusions = _(iindex).where({ op: constants.IDX_UPDATE, member: false }); + const exclusions = _(iindex).where({ op: constants.IDX_UPDATE, member: false, pub }); if (exclusions.length == 0) { throw Error('A revoked member must be excluded'); } @@ -313,7 +313,7 @@ rules.FUNCTIONS = { return true; }), - checkTxSources: (block, conf) => co(function *() { + checkTxSources: (block) => co(function *() { const txs = block.getTransactions(); for (const tx of txs) { if (!tx.inputs || tx.inputs.length == 0) { @@ -379,7 +379,7 @@ function checkSingleMembershipSignature(ms) { return keyring.verify(ms.getRaw(), ms.signature, ms.issuer); } -function getSigResult(tx, a) { +function getSigResult(tx) { let sigResult = { sigs: {}, matching: true }; let json = { "version": tx.version, "currency": tx.currency, "blockstamp": tx.blockstamp, "locktime": tx.locktime, "inputs": [], "outputs": [], "issuers": tx.issuers, "signatures": [], "comment": tx.comment }; tx.inputs.forEach(function (input) { @@ -489,7 +489,7 @@ rules.HELPERS = { } }, - getMaxPossibleVersionNumber: (current, block) => co(function*() { + getMaxPossibleVersionNumber: (current) => co(function*() { // Looking at current blockchain, find what is the next maximum version we can produce // 1. We follow previous block's version diff --git a/app/lib/streams/jsoner.js b/app/lib/streams/jsoner.js index 2b342e35a25fb9a814a7e29df4998bb41dce7269..e24820a3be99b81c0f54866093d16a72149f18f6 100644 --- a/app/lib/streams/jsoner.js +++ b/app/lib/streams/jsoner.js @@ -16,6 +16,6 @@ function JSONer () { that.push(entity.json()); done(); }; -}; +} util.inherits(JSONer, stream.Transform); diff --git a/app/lib/streams/parsers/GenericParser.js b/app/lib/streams/parsers/GenericParser.js index e5b60948c1891289caacc0e0339ba4e1b1d2ba0e..b0768144b079d6ce75198a2222564c74f4c5b40b 100644 --- a/app/lib/streams/parsers/GenericParser.js +++ b/app/lib/streams/parsers/GenericParser.js @@ -14,7 +14,7 @@ function GenericParser (captures, multipleLinesFields, rawerFunc) { this.rawerFunc = rawerFunc; - this._simpleLineExtraction = (pr, rawEntry, cap, parser) => { + this._simpleLineExtraction = (pr, rawEntry, cap) => { const fieldValue = rawEntry.match(cap.regexp); if(fieldValue && fieldValue.length >= 2){ pr[cap.prop] = cap.parser ? cap.parser(fieldValue[1], pr) : fieldValue[1]; diff --git a/app/lib/streams/parsers/block.js b/app/lib/streams/parsers/block.js index eebd6528ca487d7185a6016b86ba5e13864ad8fd..d7c5366e321656b46dfb86f4c8b55ac01dbde060 100644 --- a/app/lib/streams/parsers/block.js +++ b/app/lib/streams/parsers/block.js @@ -163,7 +163,7 @@ function splitAndMatch (separator, regexp) { }; } -function extractTransactions(raw, obj) { +function extractTransactions(raw) { const regexps = { "issuers": constants.TRANSACTION.SENDER, "inputs": constants.TRANSACTION.SOURCE_V3, diff --git a/app/lib/streams/parsers/certification.js b/app/lib/streams/parsers/certification.js index 814fe80cb15c469036adef405861e10459b4c2dd..adebc6e8944c495ba130121d6dfb0e13204c5efe 100644 --- a/app/lib/streams/parsers/certification.js +++ b/app/lib/streams/parsers/certification.js @@ -1,9 +1,7 @@ "use strict"; const GenericParser = require('./GenericParser'); const util = require('util'); -const ucp = require('../../ucp/buid'); const rawer = require('../../ucp/rawer'); -const hashf = require('../../ucp/hashf'); const constants = require('../../constants'); module.exports = CertificationParser; diff --git a/app/lib/streams/parsers/identity.js b/app/lib/streams/parsers/identity.js index bdc2c7510f6ec59ffb3a6a11ddc59abfd37b2ba7..5f405bb3a3472f2f8982dc5fe5e44d77ac8f5f0d 100644 --- a/app/lib/streams/parsers/identity.js +++ b/app/lib/streams/parsers/identity.js @@ -1,7 +1,6 @@ "use strict"; const GenericParser = require('./GenericParser'); const util = require('util'); -const ucp = require('../../ucp/buid'); const rawer = require('../../ucp/rawer'); const hashf = require('../../ucp/hashf'); const constants = require('../../constants'); diff --git a/app/lib/streams/parsers/revocation.js b/app/lib/streams/parsers/revocation.js index 52903ce60e196c3e921d4018bbf241c3538cbfec..83f8630222591ff56014b708f848cb2b68a2f444 100644 --- a/app/lib/streams/parsers/revocation.js +++ b/app/lib/streams/parsers/revocation.js @@ -1,8 +1,6 @@ "use strict"; const GenericParser = require('./GenericParser'); const util = require('util'); -const moment = require('moment'); -const ucp = require('../../ucp/buid'); const rawer = require('../../ucp/rawer'); const hashf = require('../../ucp/hashf'); const constants = require('../../constants'); diff --git a/app/lib/streams/parsers/transaction.js b/app/lib/streams/parsers/transaction.js index 06e3358becbdce182e2bab1ad49ac64564e6335d..74d3d1b225a5caf147eb85c1c86ccba3b05d87b3 100644 --- a/app/lib/streams/parsers/transaction.js +++ b/app/lib/streams/parsers/transaction.js @@ -72,7 +72,7 @@ function extractIssuers(raw) { return issuers; } -function extractInputs(raw, obj) { +function extractInputs(raw) { const inputs = []; const lines = raw.split(/\n/); for (const line of lines) { diff --git a/app/lib/streams/router.js b/app/lib/streams/router.js index c646dc64a83b3eb4de42f35d5915f211533ab4b1..0ad9fb6eb5bd3e1871cb48864582e102aa88760b 100644 --- a/app/lib/streams/router.js +++ b/app/lib/streams/router.js @@ -1,7 +1,6 @@ "use strict"; const co = require('co'); -const _ = require('underscore'); const util = require('util'); const stream = require('stream'); const Peer = require('../entity/peer'); diff --git a/app/lib/streams/routes.js b/app/lib/streams/routes.js index a6cf8ad9c16e2fd041b066e0e6df982d2a63e92f..39b980d1bc03f7c2f3168dfacf8802efc78d620e 100644 --- a/app/lib/streams/routes.js +++ b/app/lib/streams/routes.js @@ -5,7 +5,6 @@ const es = require('event-stream'); const dtos = require('./dtos'); const sanitize = require('./sanitize'); const limiter = require('../system/limiter'); -const constants = require('../../lib/constants'); const logger = require('../logger')('routes'); const WebSocketServer = require('ws').Server; diff --git a/app/lib/sync.js b/app/lib/sync.js index 6ea67b3b618cd5537780603cc96c6a7221ef59c4..6180d2b26f7346fdc4d4d6c956e6dbb2c888d0b6 100644 --- a/app/lib/sync.js +++ b/app/lib/sync.js @@ -77,12 +77,12 @@ function Synchroniser (server, host, port, conf, interactive) { if (to > 1 && speed > 0) { const remain = (to - (localNumber + 1 + blocksApplied)); const secondsLeft = remain / speed; - const momDuration = moment.duration(secondsLeft*1000); + const momDuration = moment.duration(secondsLeft * 1000); watcher.writeStatus('Remaining ' + momDuration.humanize() + ''); } }); - this.test = (to, chunkLen, askedCautious, nopeers) => co(function*() { + this.test = (to, chunkLen, askedCautious) => co(function*() { const peering = yield contacter.statics.fetchPeer(host, port, contacterOptions); const peer = new Peer(peering); const node = yield peer.connect(); @@ -197,7 +197,7 @@ function Synchroniser (server, host, port, conf, interactive) { }), // Get the remote blockchain (bc) current block - remoteCurrent: (peer) => Promise.resolve(rCurrent), + remoteCurrent: () => Promise.resolve(rCurrent), // Get the remote peers to be pulled remotePeers: () => co(function*() { @@ -775,7 +775,7 @@ function P2PDownloader(localNumber, to, toHash, peers, watcher) { * Triggers for starting the download. */ let startResolver; - const downloadStarter = new Promise((resolve, reject) => startResolver = resolve); + const downloadStarter = new Promise((resolve) => startResolver = resolve); const chainsCorrectly = (blocks, index) => co(function*() { @@ -874,7 +874,7 @@ function P2PDownloader(localNumber, to, toHash, peers, watcher) { if (doneIndex !== null) { const realIndex = slots[doneIndex]; if (downloads[realIndex].isResolved()) { - const p = new Promise((resolve, reject) => co(function*() { + co(function*() { const blocks = yield downloads[realIndex]; if (realIndex < chunks.length - 1) { // We must wait for NEXT blocks to be STRONGLY validated before going any further, otherwise we @@ -894,7 +894,7 @@ function P2PDownloader(localNumber, to, toHash, peers, watcher) { // Need a retry processing[realIndex] = false; } - })); + }); } else { processing[realIndex] = false; // Need a retry } diff --git a/app/lib/system/limiter.js b/app/lib/system/limiter.js index 29959e83dbb7063e0733f724d5e14c46ce2cb479..6fe411e35d7d98d76370f2f656599fd6ebf49c4b 100644 --- a/app/lib/system/limiter.js +++ b/app/lib/system/limiter.js @@ -111,4 +111,4 @@ function createObject(strategy) { obj.reqsMin = []; obj.reqsMinLen = 0; return obj; -} \ No newline at end of file +} diff --git a/app/lib/system/upnp.js b/app/lib/system/upnp.js index 5a562290c408a96568f4bc0b8ead259acf2f4b80..fda7375ee115a4f8854fdbe7949df499cd214c36 100644 --- a/app/lib/system/upnp.js +++ b/app/lib/system/upnp.js @@ -63,4 +63,4 @@ function openPort (localPort, remotePort) { resolve(); }); }); -} \ No newline at end of file +} diff --git a/app/lib/wizard.js b/app/lib/wizard.js index 77d2908ab8e86c83294c79a6a7f7ae6c16939c56..7e8f0c93e23bff94308b344ede1d9d8e4f67ac8b 100644 --- a/app/lib/wizard.js +++ b/app/lib/wizard.js @@ -1,6 +1,5 @@ "use strict"; const co = require('co'); -const Q = require('q'); const constants = require('./constants'); const network = require('./system/network'); const async = require('async'); @@ -348,7 +347,7 @@ function getLocalNetworkOperations(conf, autoconf) { ]; } -function getRemoteNetworkOperations(conf, remoteipv4, remoteipv6, autoconf) { +function getRemoteNetworkOperations(conf, remoteipv4) { return [ function (next){ if (!conf.ipv4) { diff --git a/app/lib/wot.js b/app/lib/wot.js index 359096a230fb44c28060e43ff237601654ac5699..d2173e31e410a84f13c0c54beee12c7f7944e010 100644 --- a/app/lib/wot.js +++ b/app/lib/wot.js @@ -45,7 +45,7 @@ function WoTBWrapper(instance) { instance.addLink(from, to); }; - this.removeLink = (from, to, debug) => { + this.removeLink = (from, to) => { logger.trace('Link %s X> %s', from, to); instance.removeLink(from, to); }; diff --git a/app/modules/config.js b/app/modules/config.js index 40920684f47f28b45d9b406b108a1c7b44a6c87e..a3f320b761069ba15bf32d768d3830b916e8ace2 100644 --- a/app/modules/config.js +++ b/app/modules/config.js @@ -6,7 +6,7 @@ module.exports = { name: 'config', desc: 'Register configuration in database', // The command does nothing particular, it just stops the process right after configuration phase is over - onConfiguredExecute: (server, conf, program, params, wizardTasks) => Promise.resolve(conf) + onConfiguredExecute: (server, conf) => Promise.resolve(conf) }] } } diff --git a/app/modules/gen.js b/app/modules/gen.js index 3fd46d132fa743a92b6371fbf747a0a828d10e82..4f185f49efc900e08cbab81b5ac6612c7f8347d4 100644 --- a/app/modules/gen.js +++ b/app/modules/gen.js @@ -18,7 +18,7 @@ module.exports = { cli: [{ name: 'gen-next [host] [port] [difficulty]', desc: 'Tries to generate the next block of the blockchain.', - onPluggedDALExecute: (server, conf, program, params, startServices, stopServices) => co(function*() { + onPluggedDALExecute: (server, conf, program, params) => co(function*() { const host = params[0]; const port = params[1]; const difficulty = params[2]; diff --git a/app/modules/synchronization.js b/app/modules/synchronization.js index 87871f12ff99b188d1426387adccb20ef4bdc54a..c389a3c13a22f55ef755149858adb37f209556d4 100644 --- a/app/modules/synchronization.js +++ b/app/modules/synchronization.js @@ -7,7 +7,7 @@ module.exports = { cli: [{ name: 'sync [host] [port] [to]', desc: 'Synchronize blockchain from a remote Duniter node', - onPluggedDALExecute: (server, conf, program, params, startServices, stopServices) => co(function*() { + onPluggedDALExecute: (server, conf, program, params) => co(function*() { const host = params[0]; const port = params[1]; const to = params[2]; diff --git a/app/service/BlockchainService.js b/app/service/BlockchainService.js index 704517dc989e56743f246ccf7824dce07c39fa2f..307b3f5258a299d466976da21e07a34b554b7806 100644 --- a/app/service/BlockchainService.js +++ b/app/service/BlockchainService.js @@ -1,12 +1,10 @@ "use strict"; -const async = require('async'); const _ = require('underscore'); const co = require('co'); const Q = require('q'); const parsers = require('../lib/streams/parsers'); const rules = require('../lib/rules'); -const keyring = require('../lib/crypto/keyring'); const constants = require('../lib/constants'); const blockchainCtx = require('../lib/computation/blockchainContext'); const blockGenerator = require('../lib/computation/blockGenerator'); @@ -30,14 +28,13 @@ function BlockchainService (server) { const mainContext = blockchainCtx(); const prover = this.prover = blockProver(server); const generator = blockGenerator(mainContext, prover); - let conf, dal, keyPair, logger, selfPubkey; + let conf, dal, logger, selfPubkey; this.getContext = () => mainContext; this.setConfDAL = (newConf, newDAL, newKeyPair) => { dal = newDAL; conf = newConf; - keyPair = newKeyPair; mainContext.setConfDAL(conf, dal); prover.setConfDAL(conf, dal, newKeyPair); generator.setConfDAL(conf, dal, newKeyPair); @@ -140,7 +137,7 @@ function BlockchainService (server) { Transaction.statics.cleanSignatories(obj.transactions); } catch (e) { - throw e; + throw e; } let existing = yield dal.getBlockByNumberAndHashOrNull(obj.number, obj.hash); if (existing) { diff --git a/app/service/PeeringService.js b/app/service/PeeringService.js index d5ee12d3e0d64a0f4f0a9e553276990e45b72858..787fbfb0fe78d05fab833f2b8e8c63167cb2ddda 100644 --- a/app/service/PeeringService.js +++ b/app/service/PeeringService.js @@ -273,7 +273,7 @@ function PeeringService(server) { logger.error('It seems there is an issue with your configuration.'); logger.error('Please restart your node with:'); logger.error('$ duniter restart'); - return Q.Promise((resolve) => null); + return Q.Promise(() => null); } // Choosing next based-block for our peer record: we basically want the most distant possible from current let minBlock = current ? current.number - 30 : 0; diff --git a/test/dal/triming.js b/test/dal/triming.js index 4fb4fc2583b21020ed2a1344b4010e68a97c9708..85678ea5c9346f2c7dd3f70355903531531eb5d1 100644 --- a/test/dal/triming.js +++ b/test/dal/triming.js @@ -1,10 +1,8 @@ "use strict"; const co = require('co'); -const _ = require('underscore'); const should = require('should'); const FileDAL = require('../../app/lib/dal/fileDAL'); const dir = require('../../app/lib/system/directory'); -const constants = require('../../app/lib/constants'); const indexer = require('../../app/lib/dup/indexer'); const toolbox = require('../integration/tools/toolbox'); const limiter = require('../../app/lib/system/limiter'); @@ -46,7 +44,7 @@ describe("Triming", function(){ yield dal.iindexDAL.insertBatch([ { op: 'CREATE', pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', uid: 'cat', created_on: '121-H', written_on: '122-H', member: true, wasMember: true, kick: false }, { op: 'UPDATE', pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', uid: null, created_on: '121-H', written_on: '123-H', member: null, wasMember: null, kick: true }, - { op: 'UPDATE', pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', uid: null, created_on: '121-H', written_on: '124-H', member: false, wasMember: null, kick: false }, + { op: 'UPDATE', pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', uid: null, created_on: '121-H', written_on: '124-H', member: false, wasMember: null, kick: false } ]); let lignes = yield dal.iindexDAL.reducable('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'); lignes.should.have.length(3); @@ -74,7 +72,7 @@ describe("Triming", function(){ { op: 'CREATE', pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', created_on: '121-H', written_on: '122-H', expires_on: 1000, expired_on: null }, { op: 'UPDATE', pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', created_on: '121-H', written_on: '123-H', expires_on: 1200, expired_on: null }, { op: 'UPDATE', pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', created_on: '121-H', written_on: '124-H', expires_on: null, expired_on: null }, - { op: 'UPDATE', pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', created_on: '121-H', written_on: '125-H', expires_on: 1400, expired_on: null }, + { op: 'UPDATE', pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', created_on: '121-H', written_on: '125-H', expires_on: 1400, expired_on: null } ]); const lignes = yield dal.mindexDAL.reducable('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'); lignes.should.have.length(4); @@ -93,7 +91,7 @@ describe("Triming", function(){ yield dal.cindexDAL.insertBatch([ { op: 'CREATE', issuer: 'HgTT', receiver: 'DNan', created_on: '121-H', written_on: '126-H', expires_on: 1000, expired_on: null }, { op: 'UPDATE', issuer: 'HgTT', receiver: 'DNan', created_on: '121-H', written_on: '126-H', expires_on: null, expired_on: 3000 }, - { op: 'CREATE', issuer: 'DNan', receiver: 'HgTT', created_on: '125-H', written_on: '126-H', expires_on: null, expired_on: null }, + { op: 'CREATE', issuer: 'DNan', receiver: 'HgTT', created_on: '125-H', written_on: '126-H', expires_on: null, expired_on: null } ]); (yield dal.cindexDAL.sqlFind({ issuer: 'HgTT' })).should.have.length(2); (yield dal.cindexDAL.sqlFind({ issuer: 'DNan' })).should.have.length(1); @@ -112,7 +110,7 @@ describe("Triming", function(){ { op: 'CREATE', identifier: 'SOURCE_1', pos: 4, written_on: '126-H', written_time: 2000, consumed: false }, { op: 'UPDATE', identifier: 'SOURCE_1', pos: 4, written_on: '139-H', written_time: 4500, consumed: true }, { op: 'CREATE', identifier: 'SOURCE_2', pos: 4, written_on: '126-H', written_time: 2000, consumed: false }, - { op: 'CREATE', identifier: 'SOURCE_3', pos: 4, written_on: '126-H', written_time: 2000, consumed: false }, + { op: 'CREATE', identifier: 'SOURCE_3', pos: 4, written_on: '126-H', written_time: 2000, consumed: false } ]); (yield dal.sindexDAL.sqlFind({ identifier: 'SOURCE_1' })).should.have.length(2); (yield dal.sindexDAL.sqlFind({ pos: 4 })).should.have.length(4); @@ -138,7 +136,7 @@ describe("Triming", function(){ medianTimeBlocks: 3 })).s1; // const s1 = server.s1; - for (const i of new Array(13)) { + for (let i = 0; i < 13; i++) { yield server.commit(); } (yield server.dal.bindexDAL.head(1)).should.have.property('number').equal(12); diff --git a/test/eslint.js b/test/eslint.js index bcb4e0fbf533f0402594467c4669a060afaa5bf4..24994f994e1cf09c918a364227605f4855d01650 100644 --- a/test/eslint.js +++ b/test/eslint.js @@ -1,16 +1,16 @@ -var lint = require('mocha-eslint'); +const lint = require('mocha-eslint'); // Array of paths to lint // Note: a seperate Mocha test will be run for each path and each file which // matches a glob pattern -var paths = [ +const paths = [ 'app', 'bin/duniter', 'test' ]; // Specify style of output -var options = {}; +const options = {}; options.formatter = 'stylish'; // Run the tests diff --git a/test/fast/javascript_test.js b/test/fast/javascript_test.js deleted file mode 100644 index c0063cbdccb723fb20e7e83d405303d014403283..0000000000000000000000000000000000000000 --- a/test/fast/javascript_test.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -var should = require('should'); -var co = require('co'); - -describe('JavaScript', () => { - - describe('for loops', () => { - - const array1 = [1, 2, 3]; - array1.abc = 2; - - it('for (.. in ..)', () => { - array1.abc = 2; - let sum = 0; - for (const i in array1) { - sum += array1[i]; - } - sum.should.equal(8); // <-- Yes, it does not equal 6! Because `for .. in` is not `hasOwnProperty` checked. - }); - - it('for (.. of ..)', () => { - let sum = 0; - for (const value of array1) { - sum += value; - } - sum.should.equal(6); - }); - - it('with promises', () => co(function*() { - let sum = 0; - for (const value of array1) { - sum += yield Promise.resolve(value); - } - sum.should.equal(6); - })); - }); -}); diff --git a/test/integration/proof-of-work.js b/test/integration/proof-of-work.js index 472ddd4e18fb7112eb54a6d0540f375c78044445..7a14a0c9d6435f4a0de93a0cfe1545b5fc7e716e 100644 --- a/test/integration/proof-of-work.js +++ b/test/integration/proof-of-work.js @@ -55,20 +55,6 @@ describe("Proof-of-work", function() { intermediateProofs[intermediateProofs.length - 1].pow.should.have.property('hash').equal(block.hash); })); - it('should be possible to make the prover make us wait until we trigger it again', () => co(function*() { - let waitPromise = prover.waitForNewAsking(); - return Promise.all([ - waitPromise, - co(function*() { - yield new Promise((resolve) => setTimeout(resolve, 10)); - yield prover.prove({ - issuer: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', - number: 2 - }, MUST_START_WITH_A_ZERO, now); - }) - ]); - })); - // Too randomly successing test // it('should be able to cancel a proof-of-work on other PoW receival', () => co(function*() { // const now = 1474464489;