add redeploy; don't reload compiler if it's already loaded

This commit is contained in:
Iuri Matias 2017-02-25 15:47:35 -05:00
parent d73eb802ea
commit e9ce9dc6f1
5 changed files with 50 additions and 32 deletions

View File

@ -71,11 +71,15 @@ Compiler.prototype.compile_solidity = function(contractFiles, cb) {
},
function loadCompiler(callback) {
// TODO: there ino need to load this twice
self.logger.info("loading solc compiler..");
solcW = new SolcW();
solcW.load_compiler(function(){
if (solcW.isCompilerLoaded()) {
callback();
});
} else {
self.logger.info("loading solc compiler..");
solcW.load_compiler(function(){
callback();
});
}
},
function compileContracts(callback) {
self.logger.info("compiling contracts...");

View File

@ -1,20 +1,27 @@
var solcProcess = require('child_process').fork(__dirname + '/solcP.js');
var compilerLoaded = false;
var SolcW = function() {
};
SolcW.prototype.load_compiler = function(done) {
solcProcess.on('message', function(msg) {
if (compilerLoaded) { done(); }
solcProcess.once('message', function(msg) {
if (msg.result !== 'loadedCompiler') {
return;
}
compilerLoaded = true;
done();
});
solcProcess.send({action: 'loadCompiler'});
};
SolcW.prototype.isCompilerLoaded = function() {
return (compilerLoaded === true);
}
SolcW.prototype.compile = function(obj, optimize, done) {
solcProcess.on('message', function(msg) {
solcProcess.once('message', function(msg) {
if (msg.result !== 'compilation') {
return;
}

5
lib/core/core.js Normal file
View File

@ -0,0 +1,5 @@
var Core = function() {};
module.exports = Core;

View File

@ -115,6 +115,7 @@ var Embark = {
}
callback();
},
// can be done in paralell
function monitorServices(callback) {
if (!options.useDashboard) {
@ -132,18 +133,6 @@ var Embark = {
callback();
},
function deploy(callback) {
var deployManager = new DeployManager({
config: Embark.config,
logger: Embark.logger,
plugins: self.plugins,
events: self.events
});
deployManager.deployContracts(function() {
callback();
});
},
function buildPipeline(callback) {
self.logger.setStatus("Building Assets");
@ -160,29 +149,41 @@ var Embark = {
callback();
},
function deploy(callback) {
var deployManager = new DeployManager({
config: Embark.config,
logger: Embark.logger,
plugins: self.plugins,
events: self.events
});
deployManager.deployContracts(function() {
callback();
});
self.events.on('file-event', function(fileType, path) {
if (fileType === 'contract' || fileType === 'config') {
self.config.reloadConfig();
deployManager.deployContracts(function() {});
}
});
self.events.on('file-event', function(fileType, path) {
if (fileType === 'asset') {
// TODO: can just rebuild pipeline, no need to deploy contracts
// again
self.config.reloadConfig();
deployManager.deployContracts(function() {});
}
});
},
function watchFilesForChanges(callback) {
self.logger.setStatus("Watching for changes");
var watch = new Watch({logger: self.logger, events: self.events});
watch.start();
self.events.on('file-event', function(fileType, path) {
if (fileType === 'contract' || fileType === 'config') {
self.logger.info("received redeploy event");
//Embark.redeploy();
}
});
self.events.on('rebuildAssets', function(fileType, path) {
if (fileType === 'asset') {
self.logger.info("received rebuildAssets event");
// TODO: can just rebuild pipeline, no need to deploy contracts
// again
//Embark.redeploy();
}
});
callback();
},
function startAssetServer(callback) {
if (!options.runWebserver) {
return callback();

View File

@ -9,6 +9,7 @@ contract Token {
mapping( address => uint ) _balances;
mapping( address => mapping( address => uint ) ) _approvals;
uint public _supply;
//uint public _supply2;
function Token( uint initial_balance ) {
_balances[msg.sender] = initial_balance;
_supply = initial_balance;