mirror of https://github.com/embarklabs/embark.git
make groups of dependencyCount to do async by group
This commit is contained in:
parent
c5a39649b9
commit
3c952f89ed
|
@ -258,8 +258,42 @@ class ContractsManager {
|
|||
});
|
||||
}
|
||||
callback();
|
||||
},
|
||||
function setDependencyCount(callback) {
|
||||
let className;
|
||||
|
||||
function getDependencyCount(contractName, cycleDetector) {
|
||||
if (!self.contractDependencies[contractName] || !self.contractDependencies[contractName].length) {
|
||||
self.contracts[contractName].dependencyCount = 0;
|
||||
return 0;
|
||||
}
|
||||
if (self.contracts[contractName].dependencyCount) {
|
||||
// Already have that count
|
||||
return self.contracts[contractName].dependencyCount;
|
||||
}
|
||||
let total = self.contractDependencies[contractName].length;
|
||||
self.contractDependencies[contractName].some(dependencyName => {
|
||||
if (cycleDetector.indexOf(dependencyName) > -1) {
|
||||
// We are in a cycle because of the dependency, set both to Infinity
|
||||
self.contracts[dependencyName].dependencyCount = Infinity;
|
||||
total = Infinity;
|
||||
return true;
|
||||
}
|
||||
cycleDetector.push(dependencyName);
|
||||
total += getDependencyCount(dependencyName, cycleDetector);
|
||||
});
|
||||
self.contracts[contractName].dependencyCount = total;
|
||||
return total;
|
||||
}
|
||||
|
||||
let cycleDetector;
|
||||
for (className in self.contracts) {
|
||||
cycleDetector = [];
|
||||
getDependencyCount(className, cycleDetector);
|
||||
}
|
||||
callback();
|
||||
}
|
||||
], function (err, _result) {
|
||||
], function (err) {
|
||||
if (err) {
|
||||
self.compileError = true;
|
||||
self.events.emit("status", __("Compile/Build error"));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
let async = require('async');
|
||||
const _ = require('underscore');
|
||||
|
||||
class DeployManager {
|
||||
constructor(options) {
|
||||
|
@ -31,12 +32,15 @@ class DeployManager {
|
|||
self.logger.info(__("deploying contracts"));
|
||||
self.events.emit("deploy:beforeAll");
|
||||
|
||||
async.eachOfSeries(contracts,
|
||||
function (contract, key, callback) {
|
||||
contract._gasLimit = self.gasLimit;
|
||||
self.events.request('deploy:contract', contract, (err) => {
|
||||
callback(err);
|
||||
});
|
||||
const contractsPerDependencyCount = _.groupBy(contracts, 'dependencyCount');
|
||||
async.eachSeries(contractsPerDependencyCount,
|
||||
function (parallelGroups, callback) {
|
||||
async.each(parallelGroups, (contract, eachCb) => {
|
||||
contract._gasLimit = self.gasLimit;
|
||||
self.events.request('deploy:contract', contract, (err) => {
|
||||
eachCb(err);
|
||||
});
|
||||
}, callback);
|
||||
},
|
||||
function (err, _results) {
|
||||
if (err) {
|
||||
|
|
Loading…
Reference in New Issue