Fix race condition on deploy tracker

This commit is contained in:
Anthony Laibe 2018-09-22 14:43:10 +01:00
parent 94758a1ea4
commit e20d7bfc6a
2 changed files with 61 additions and 58 deletions

View File

@ -41,7 +41,11 @@ class DeployManager {
deployAll(done) {
let self = this;
async.waterfall([
function loadTracker(next) {
self.events.request("deployTracker:load", next);
},
function doDeployAll() {
self.events.request('contracts:dependencies', (err, contractDependencies) => {
self.events.request('contracts:list', (err, contracts) => {
if (err) {
@ -99,6 +103,8 @@ class DeployManager {
});
});
}
]);
}
deployContracts(done) {
let self = this;

View File

@ -19,7 +19,7 @@ class DeployTracker {
registerEvents() {
const self = this;
this.events.on("deploy:beforeAll", this.setCurrentChain.bind(this));
this.events.setCommandHandler("deployTracker:load", this.setCurrentChain.bind(this));
this.events.on("deploy:contract:deployed", (contract) => {
self.trackContract(contract.className, contract.realRuntimeBytecode, contract.realArgs, contract.deployedAddress);
@ -43,15 +43,12 @@ class DeployTracker {
});
}
// TODO: just an event might not be enought to the async nature
// it needs to be a plugin api before deploy, that makes the deployment wait
setCurrentChain() {
setCurrentChain(cb) {
const self = this;
if (this.chainConfig === false) {
this.currentChain = {contracts: []};
//return cb();
return cb();
}
this.events.request("blockchain:block:byNumber", 0, function(_err, block) {
let chainId = block.hash;
@ -62,7 +59,7 @@ class DeployTracker {
self.currentChain = self.chainConfig[chainId];
self.currentChain.name = self.env;
//cb();
cb();
});
}