Added coin/dogecoin at gitignore so we don't mess around with payment addresses

Fixed merge shit
This commit is contained in:
Andrea Baccega 2014-01-13 23:30:31 +01:00
parent be51126f09
commit 6ad310b872
4 changed files with 30 additions and 26 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
example/coins/dogecoin.json
*.py *.py

View File

@ -3,10 +3,10 @@
"symbol": "doge", "symbol": "doge",
"algorithm": "scrypt", "algorithm": "scrypt",
"reward": "POW", "reward": "POW",
"address": "DDt79i6P3Wro3SD3HSnkRLpMgUGUGdiNhS", "address": "n3s8iDk1onxyY2nuC1k4HoRQFGJ7BhjFcq",
"stratumPort": 3334, "stratumPort": 3334,
"difficulty": 8, "difficulty": 8,
"blockRefreshInterval": 60, "blockRefreshInterval": 1,
"merkleRefreshInterval": 60, "merkleRefreshInterval": 60,
"daemon": { "daemon": {
"host": "localhost", "host": "localhost",

View File

@ -12,7 +12,7 @@ var util = require('./libs/util.js');
* - 'started'() - when the pool is effectively started. * - 'started'() - when the pool is effectively started.
* - 'share'(isValid, dataObj) - In case it's valid the dataObj variable will contain (TODO) and in case it's invalid (TODO) * - 'share'(isValid, dataObj) - In case it's valid the dataObj variable will contain (TODO) and in case it's invalid (TODO)
*/ */
var pool = module.exports = function pool(coin, authFn){ var pool = module.exports = function pool(coin, authorizeFn){
var _this = this; var _this = this;
var publicKeyBuffer; var publicKeyBuffer;
@ -25,11 +25,11 @@ var pool = module.exports = function pool(coin, authFn){
function SetupJobManager(){ function SetupJobManager(){
this.jobManager = new jobManager({ _this.jobManager = new jobManager({
algorithm: coin.options.algorithm, algorithm : coin.options.algorithm,
address: coin.options.address address : coin.options.address
}); });
this.jobManager.on('newBlock', function(blockTemplate){ _this.jobManager.on('newBlock', function(blockTemplate){
if ( typeof(_this.stratumServer ) === 'undefined') { if ( typeof(_this.stratumServer ) === 'undefined') {
console.warn("Stratum server still not started! cannot broadcast block!"); console.warn("Stratum server still not started! cannot broadcast block!");
} else { } else {
@ -62,8 +62,8 @@ var pool = module.exports = function pool(coin, authFn){
function SetupDaemonInterface(){ function SetupDaemonInterface(){
console.log('Connecting to daemon for ' + coin.options.name); console.log('Connecting to daemon for ' + coin.options.name);
this.daemon = new daemon.interface(coin.options.daemon); _this.daemon = new daemon.interface(coin.options.daemon);
this.daemon.on('online', function(){ _this.daemon.on('online', function(){
async.parallel({ async.parallel({
addressInfo: function(callback){ addressInfo: function(callback){
_this.daemon.cmd('validateaddress', _this.daemon.cmd('validateaddress',
@ -72,13 +72,13 @@ var pool = module.exports = function pool(coin, authFn){
if (error){ if (error){
console.log('validateaddress rpc error for ' + coin.options.name); console.log('validateaddress rpc error for ' + coin.options.name);
callback(error); callback(error);
} } else if (!result.isvalid) {
else if (!result.isvalid){
console.log('address is not valid for ' + coin.options.name); console.log('address is not valid for ' + coin.options.name);
callback(error); callback("address-not-valid");
} } else {
else console.log("LOALASD"+JSON.stringify(result))
callback(error, result); callback(error, result);
}
} }
); );
}, },
@ -95,6 +95,7 @@ var pool = module.exports = function pool(coin, authFn){
} }
}, function(err, results){ }, function(err, results){
if (err) return; if (err) return;
console.log('Connected to daemon for ' + coin.options.name); console.log('Connected to daemon for ' + coin.options.name);
coin.options.hasSubmitMethod = results.submitMethod; coin.options.hasSubmitMethod = results.submitMethod;
@ -103,7 +104,6 @@ var pool = module.exports = function pool(coin, authFn){
util.script_to_pubkey(results.addressInfo.pubkey); util.script_to_pubkey(results.addressInfo.pubkey);
StartStratumServer(); StartStratumServer();
GetBlockTemplate();
SetupBlockPolling(); SetupBlockPolling();
}); });
@ -134,7 +134,10 @@ var pool = module.exports = function pool(coin, authFn){
var clientThis = this; var clientThis = this;
//if (clientThis.authorized) { //if (clientThis.authorized) {
clientThis.sendMiningJob(_this.jobManager.currentJob.getJobParams()); if (typeof(_this.jobManager.currentJob) !== 'undefined') {
clientThis.sendMiningJob(_this.jobManager.currentJob.getJobParams());
}
//} //}
}).on('submit', function(params, resultCallback){ }).on('submit', function(params, resultCallback){
@ -186,15 +189,14 @@ var pool = module.exports = function pool(coin, authFn){
var pollTimeout; var pollTimeout;
var setPoll; var setPoll;
setPoll = function(){ setInterval(function () {
pollTimeout = setTimeout(function(){ GetBlockTemplate(function(error, result) {
GetBlockTemplate(function(error, result) { if (error)
if (error) console.error("Block polling error getting block template for " + coin.options.name);
console.error("Block polling error getting block template for " + coin.options.name);
setPoll(); });
});
}, pollingInterval); }, pollingInterval);
};
console.log('Block polling setup for every ' + pollingInterval + ' milliseconds for ' + coin.options.name); console.log('Block polling setup for every ' + pollingInterval + ' milliseconds for ' + coin.options.name);
} }

View File

@ -64,9 +64,10 @@ var JobManager = module.exports = function JobManager(options){
* used by onNewTemplate * used by onNewTemplate
**/ **/
function CheckNewIfNewBlock(prevBlockHash){ function CheckNewIfNewBlock(prevBlockHash){
var newBlock = true; var newBlock = true;
for(var job in jobs){ for(var job in jobs){
if (jobs[job].rpcData.previousblockhash === blockTemplate.rpcData.previousblockhash) { if (jobs[job].rpcData.previousblockhash === prevBlockHash) {
newBlock = false; newBlock = false;
} }
} }