Merge pull request #86 from cubedro/develop

Added coinbase + refactoring
This commit is contained in:
Marian OANCΞA 2015-04-24 13:22:41 +03:00
commit d09ddfa700
1 changed files with 51 additions and 27 deletions

View File

@ -17,6 +17,7 @@ var ETH_VERSION,
API_VERSION;
var INSTANCE_NAME = process.env.INSTANCE_NAME;
var COINBASE = '';
var Contract = null;
@ -53,6 +54,7 @@ function Node()
NET_VERSION = web3.version.network;
PROTOCOL_VERSION = web3.toDecimal(web3.version.ethereum);
API_VERSION = web3.version.api;
COINBASE = web3.eth.coinbase;
}
catch (err) {
console.error("Couldn't get version");
@ -68,7 +70,8 @@ function Node()
port: (process.env.LISTENING_PORT || 30303),
os: os.platform(),
os_v: os.release(),
client: pjson.version
client: pjson.version,
coinbase: COINBASE
};
this.id = _.camelCase(this.info.name);
@ -326,18 +329,18 @@ Node.prototype.getMinerName = function(miner)
}
else
{
var name = this._Registrar.name(miner);
if(this._Registrar !== null)
{
var name = this._Registrar.name(miner);
if(name.length > 0)
{
this._knownMiners.push({miner: miner, name: name});
return name;
}
else
{
this._knownMiners.push({miner: miner, name: false});
return false;
if(name.length > 0)
{
this._knownMiners.push({miner: miner, name: name});
return name;
}
}
this._knownMiners.push({miner: miner, name: false});
}
return false;
@ -480,21 +483,35 @@ Node.prototype.setWatches = function()
{
var self = this;
this.pendingFilter = web3.eth.filter('pending');
this.pendingFilter.watch( function(log) {
if(PENDING_WORKS) {
debounce(function() {
self.updatePending();
}, 50);
}
});
try {
this.pendingFilter = web3.eth.filter('pending');
this.pendingFilter.watch( function(log) {
if(PENDING_WORKS) {
debounce(function() {
self.updatePending();
}, 50);
}
});
}
catch (err)
{
console.error("Couldn't set up pending filter");
console.error(err);
}
this.chainFilter = web3.eth.filter('latest');
this.chainFilter.watch(function(log) {
debounce(function() {
self.update();
}, 50);
});
try {
this.chainFilter = web3.eth.filter('latest');
this.chainFilter.watch(function(log) {
debounce(function() {
self.update();
}, 50);
});
}
catch (err)
{
console.error("Couldn't set up chain filter");
console.error(err);
}
this.updateInterval = setInterval(function(){
self.update();
@ -519,8 +536,15 @@ Node.prototype.emit = function(message, payload)
Node.prototype.installContract = function()
{
Contract = web3.eth.contract(registrar.desc);
this._Registrar = new Contract(registrar.address);
try {
Contract = web3.eth.contract(registrar.desc);
this._Registrar = new Contract(registrar.address);
}
catch (err)
{
console.error("Couldn't set up registrar contract");
console.error(err);
}
}
Node.prototype.init = function()