Delay contract deploiement if share bytecode
This commit is contained in:
parent
13ab52125a
commit
527dbcca8b
|
@ -20,6 +20,7 @@ class BlockchainConnector {
|
|||
this.isDev = options.isDev;
|
||||
this.web3Endpoint = '';
|
||||
this.isWeb3Ready = false;
|
||||
this.deployers = {};
|
||||
|
||||
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
|
||||
cb(self.isWeb3Ready);
|
||||
|
@ -232,9 +233,29 @@ class BlockchainConnector {
|
|||
}
|
||||
|
||||
deployContractFromObject(deployContractObject, params, cb) {
|
||||
let deployer = this.deployers[deployContractObject._deployData];
|
||||
|
||||
if (!deployer) {
|
||||
deployer = {running: false, requested: []};
|
||||
this.deployers[deployContractObject._deployData] = deployer;
|
||||
}
|
||||
|
||||
if (deployer.running) {
|
||||
deployer.requested.push({deployContractObject, params, cb});
|
||||
return;
|
||||
}
|
||||
|
||||
deployer.running = true;
|
||||
embarkJsUtils.secureSend(this.web3, deployContractObject, {
|
||||
from: params.from, gas: params.gas, gasPrice: params.gasPrice
|
||||
}, true, cb);
|
||||
}, true, (error, receipt) => {
|
||||
deployer.running = false;
|
||||
if (deployer.requested.length > 0) {
|
||||
let request = deployer.requested.shift();
|
||||
this.deployContractFromObject(request.deployContractObject, request.params, request.cb);
|
||||
}
|
||||
cb(error, receipt);
|
||||
});
|
||||
}
|
||||
|
||||
determineDefaultAccount(cb) {
|
||||
|
|
Loading…
Reference in New Issue