From 8cee44cbd7ae8cc4dba001498facc27eff63a3d0 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 15 May 2018 14:42:06 -0400 Subject: [PATCH 1/2] conflict in package lock --- lib/core/engine.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/core/engine.js b/lib/core/engine.js index 5e21fa50..da5c7169 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -146,16 +146,9 @@ class Engine { plugins: this.plugins }); - const queue = async.queue((task, callback) => { - pipeline.build(task.abi, task.contractsJSON, task.path, callback); - }, 1); - this.events.on('code-generator-ready', function () { self.events.request('code', function (abi, contractsJSON) { - self.currentAbi = abi; - self.contractsJSON = contractsJSON; - - queue.push({abi, contractsJSON, path: null}, () => { + pipeline.build(abi, contractsJSON, null, () => { if (self.watch) { self.watch.restart(); // Necessary because changing a file while it is writing can stop it from being watched } @@ -168,7 +161,7 @@ class Engine { codeGeneratorService(_options) { let self = this; - let generateCode = function (contractsManager) { + const generateCode = function (contractsManager) { let codeGenerator = new CodeGenerator({ blockchainConfig: self.config.blockchainConfig, contractsConfig: self.config.contractsConfig, @@ -183,9 +176,17 @@ class Engine { self.events.emit('code-generator-ready'); }); }; - this.events.on('contractsDeployed', generateCode); - this.events.on('blockchainDisabled', generateCode); - this.events.on('asset-changed', generateCode); + const cargo = async.cargo((tasks, callback) => { + generateCode(tasks[tasks.length - 1].contractsManager); + self.events.once('outputDone', callback); + }); + const addToCargo = function (contractsManager) { + cargo.push({contractsManager}); + }; + + this.events.on('contractsDeployed', addToCargo); + this.events.on('blockchainDisabled', addToCargo); + this.events.on('asset-changed', addToCargo); } deploymentService(options) { @@ -226,9 +227,13 @@ class Engine { // TODO: still need to redeploy contracts because the original contracts // config is being corrupted if (fileType === 'asset') { - self.events.emit('asset-changed', self.contractsManager); + // Throttle file changes so we re-write only once for all files + clearTimeout(self.fileTimeout); + self.fileTimeout = setTimeout(() => { + self.events.emit('asset-changed', self.contractsManager); + }, 50); } - // TODO: for now need to deploy on asset chanes as well + // TODO: for now need to deploy on asset changes as well // because the contractsManager config is corrupted after a deploy if (fileType === 'contract' || fileType === 'config') { self.config.reloadConfig(); From 38cf7a4aa8da54e0d29b1b633cdff8ed21f45449 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 15 May 2018 15:41:24 -0400 Subject: [PATCH 2/2] throttle contracts too --- lib/core/engine.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/core/engine.js b/lib/core/engine.js index da5c7169..18bb6682 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -224,22 +224,22 @@ class Engine { }); this.events.on('file-event', function (fileType) { - // TODO: still need to redeploy contracts because the original contracts - // config is being corrupted - if (fileType === 'asset') { - // Throttle file changes so we re-write only once for all files - clearTimeout(self.fileTimeout); - self.fileTimeout = setTimeout(() => { + clearTimeout(self.fileTimeout); + self.fileTimeout = setTimeout(() => { + // TODO: still need to redeploy contracts because the original contracts + // config is being corrupted + if (fileType === 'asset') { + // Throttle file changes so we re-write only once for all files self.events.emit('asset-changed', self.contractsManager); - }, 50); - } - // TODO: for now need to deploy on asset changes as well - // because the contractsManager config is corrupted after a deploy - if (fileType === 'contract' || fileType === 'config') { - self.config.reloadConfig(); - self.deployManager.deployContracts(function () { - }); - } + } + // TODO: for now need to deploy on asset changes as well + // because the contractsManager config is corrupted after a deploy + if (fileType === 'contract' || fileType === 'config') { + self.config.reloadConfig(); + self.deployManager.deployContracts(function () { + }); + } + }, 50); }); }