diff --git a/app/service/BlockchainService.js b/app/service/BlockchainService.js index 81e79d96187bdc18836996c710fa18522147852f..6628d7af11fc4dd178b704959a6a9634f38a31f6 100644 --- a/app/service/BlockchainService.js +++ b/app/service/BlockchainService.js @@ -7,7 +7,6 @@ const parsers = require('../lib/streams/parsers'); const rules = require('../lib/rules'); const constants = require('../lib/constants'); const blockchainCtx = require('../lib/computation/blockchainContext'); -const blockGenerator = require('duniter-prover').duniter.methods.blockGenerator; const Block = require('../lib/entity/block'); const Identity = require('../lib/entity/identity'); const Transaction = require('../lib/entity/transaction'); @@ -272,8 +271,7 @@ function BlockchainService (server) { let certsPending = []; let mssPending = []; try { - const generator = blockGenerator(server); - const join = yield generator.getSinglePreJoinData(current, idty.hash); + const join = yield server.generatorGetJoinData(current, idty.hash, 'a'); const pubkey = join.identity.pubkey; // Check WoT stability const someNewcomers = join.identity.wasMember ? [] : [join.identity.pubkey]; @@ -293,8 +291,8 @@ function BlockchainService (server) { ms.type = ms.membership return ms }); - const newCerts = yield generator.computeNewCerts(nextBlockNumber, [join.identity.pubkey], joinData, updates); - const newLinks = generator.newCertsToLinks(newCerts, updates); + const newCerts = yield server.generatorComputeNewCerts(nextBlockNumber, [join.identity.pubkey], joinData, updates); + const newLinks = yield server.generatorNewCertsToLinks(newCerts, updates); const currentTime = current ? current.medianTime : 0; certs = yield that.getValidCerts(pubkey, newCerts); outdistanced = yield rules.HELPERS.isOver3Hops(pubkey, newLinks, someNewcomers, current, conf, dal); diff --git a/index.js b/index.js index 711bcd5a1a2ce1cf91cc91be002226dd877a91a3..e82aa0f8046f871967d0128f0680943d86e4c3b2 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,6 @@ const reapplyDependency = require('./app/modules/reapply'); const revertDependency = require('./app/modules/revert'); const daemonDependency = require('./app/modules/daemon'); const pSignalDependency = require('./app/modules/peersignal'); -const proverDependency = require('duniter-prover');//require('./app/modules/prover'); const routerDependency = require('./app/modules/router'); const MINIMAL_DEPENDENCIES = [ @@ -41,7 +40,6 @@ const DEFAULT_DEPENDENCIES = MINIMAL_DEPENDENCIES.concat([ ]); const PRODUCTION_DEPENDENCIES = DEFAULT_DEPENDENCIES.concat([ - { name: 'duniter-prover', required: proverDependency } ]); module.exports = function (home, memory, overConf) { diff --git a/package.json b/package.json index 29a6cd3b752ad2c0ffc8802d2d71f191e0c87e4c..1e98372bfda1026458abaa02ac7cbd3ca21fb7ec 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "commander": "2.9.0", "daemonize2": "0.4.2", "duniter-common": "^1.0.0", - "duniter-prover": "^1.0.2", "event-stream": "3.3.4", "inquirer": "3.0.6", "jison": "0.4.17", @@ -71,6 +70,7 @@ "duniter-bma": "^1.0.7", "duniter-crawler": "^1.0.7", "duniter-keypair": "^1.0.1", + "duniter-prover": "^1.0.3", "eslint": "3.13.1", "eslint-plugin-mocha": "4.8.0", "istanbul": "0.4.0", diff --git a/server.js b/server.js index 13acc4e2828550ef413796e3c8042b576e63fe07..2f505d54de53ed66b2dc2f5659ceebdb6653a98f 100644 --- a/server.js +++ b/server.js @@ -376,6 +376,21 @@ function Server (home, memoryOnly, overrideConf) { * Default endpoint. To be overriden by a module to specify another endpoint value (for ex. BMA). */ this.getMainEndpoint = () => Promise.resolve('DEFAULT_ENDPOINT') + + /** + * Default WoT incoming data for new block. To be overriden by a module. + */ + this.generatorGetJoinData = () => Promise.resolve({}) + + /** + * Default WoT incoming certifications for new block, filtering wrong certs. To be overriden by a module. + */ + this.generatorComputeNewCerts = () => Promise.resolve({}) + + /** + * Default WoT transforming method for certs => links. To be overriden by a module. + */ + this.generatorNewCertsToLinks = () => Promise.resolve({}) } util.inherits(Server, stream.Duplex); diff --git a/test/integration/identity-expiry.js b/test/integration/identity-expiry.js index c43753cdde9af2c46181a768936c6a22e23fdfb9..b19e084af91fa9838cd8393157b2aa464a74eedd 100644 --- a/test/integration/identity-expiry.js +++ b/test/integration/identity-expiry.js @@ -5,6 +5,7 @@ const co = require('co'); const should = require('should'); const duniter = require('../../index'); const bma = require('duniter-bma').duniter.methods.bma; +const prover = require('duniter-prover').duniter.methods; const user = require('./tools/user'); const constants = require('../../app/lib/constants'); const rp = require('request-promise'); @@ -52,6 +53,7 @@ describe("Identities expiry", function() { return co(function *() { yield s1.initWithDAL().then(bma).then((bmapi) => bmapi.openConnections()); + prover.hookServer(s1) yield cat.createIdentity(); yield tac.createIdentity(); yield tic.createIdentity(); diff --git a/test/integration/identity-kicking.js b/test/integration/identity-kicking.js index aaae7d4a6392cc83262f4e391a8bc5f8614f7f35..7846cc522d0cfc61622cf09573a0c239eaa64666 100644 --- a/test/integration/identity-kicking.js +++ b/test/integration/identity-kicking.js @@ -50,6 +50,7 @@ describe("Identities kicking", function() { const now = Math.round(new Date().getTime() / 1000); yield s1.initWithDAL().then(bma).then((bmapi) => bmapi.openConnections()); + require('duniter-prover').duniter.methods.hookServer(s1); yield cat.createIdentity(); yield tac.createIdentity(); yield cat.cert(tac); diff --git a/test/integration/identity-test.js b/test/integration/identity-test.js index 63f2b4a0e0b105f4e9183ba86d593a05603837d2..df77d9ddf1f1678db20b6c1c698aa619259287fe 100644 --- a/test/integration/identity-test.js +++ b/test/integration/identity-test.js @@ -54,6 +54,7 @@ describe("Identities collision", function() { return co(function *() { yield s1.initWithDAL().then(bma).then((bmapi) => bmapi.openConnections()); + require('duniter-prover').duniter.methods.hookServer(s1); yield cat.createIdentity(); yield tac.createIdentity(); yield toc.createIdentity(); diff --git a/test/integration/tools/toolbox.js b/test/integration/tools/toolbox.js index d5aa05c505c53dd01e0048752d3fbda39382a1aa..8a42e7fef26a7794673d7af7367ed2740c06b322 100644 --- a/test/integration/tools/toolbox.js +++ b/test/integration/tools/toolbox.js @@ -298,6 +298,8 @@ module.exports = { yield bmaAPI.openConnections(); server.bma = bmaAPI; require('../../../app/modules/router').duniter.methods.routeToNetwork(server); + // Extra: for /wot/requirements URL + require('duniter-prover').duniter.methods.hookServer(server); }); let prover;