Fixed block submission hex.
This commit is contained in:
parent
43517a8824
commit
cb1e40d8eb
@ -44,6 +44,12 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, publ
|
||||
extraNoncePlaceholder
|
||||
);
|
||||
|
||||
/**
|
||||
* Checks if the rpcData provided as argument contains the same previousblockhash of the current job.
|
||||
**/
|
||||
this.isRPCDataFromSameBlock = function(rpcData) {
|
||||
return this.rpcData.previousblockhash == rpcData.previousblockhash;
|
||||
}
|
||||
this.serializeCoinbase = function(extraNonce1, extraNonce2){
|
||||
return Buffer.concat([
|
||||
this.generationTransaction.coinbase[0],
|
||||
@ -71,7 +77,7 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, publ
|
||||
this.serializeBlock = function(header, coinbase){
|
||||
return Buffer.concat([
|
||||
header,
|
||||
util.varIntBuffer(this.rpcData.transaction.length + 1),
|
||||
util.varIntBuffer(this.rpcData.transactions.length + 1),
|
||||
coinbase,
|
||||
this.transactionData
|
||||
]);
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
"symbol": "doge",
|
||||
"algorithm": "scrypt",
|
||||
"reward": "POW",
|
||||
"address": "DDt79i6P3Wro3SD3HSnkRLpMgUGUGdiNhS",
|
||||
"address": "mkLyYQ5U8aFQ8aDAF1GS9zXStTzi3m29Tg",
|
||||
"stratumPort": 3334,
|
||||
"difficulty": 8,
|
||||
"daemon": {
|
||||
"host": "localhost",
|
||||
"port": 8332,
|
||||
"user": "test",
|
||||
"password": "test"
|
||||
"port": 19334,
|
||||
"user": "testnet",
|
||||
"password": "AHhQYqfSZqzQvkSXAtHtDAbKaZaoPih3wfmJfgCtjRx9"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"blockNotifyListener": {
|
||||
"enabled": true,
|
||||
"enabled": false,
|
||||
"port": 8117,
|
||||
"password": "test"
|
||||
}
|
||||
|
||||
@ -55,6 +55,11 @@ function DaemonInterface(options){
|
||||
params: params
|
||||
});
|
||||
|
||||
if (method == 'submitblock') {
|
||||
console.log("SUBMITBLOCK daemon");
|
||||
console.log(requestJson);
|
||||
}
|
||||
|
||||
var options = {
|
||||
hostname: 'localhost',
|
||||
port: _this.options.port,
|
||||
|
||||
13
init.js
13
init.js
@ -42,6 +42,7 @@ fs.readdir(confFolder, function(err, files){
|
||||
|
||||
|
||||
if (config.blockNotifyListener.enabled){
|
||||
console.log("ENABLED");
|
||||
var blockNotifyServer = net.createServer(function(c) {
|
||||
console.log('server connected');
|
||||
var data = '';
|
||||
@ -69,4 +70,16 @@ if (config.blockNotifyListener.enabled){
|
||||
});
|
||||
});
|
||||
blockNotifyServer.listen(config.blockNotifyListener.port, function() {});
|
||||
} else {
|
||||
console.log("NOT ENABLED");
|
||||
// If blockNotifyListener isn't enabled then we need to set up some polling parameters.
|
||||
var pollingTime = typeof(config.blockPollingTime) === 'undefined' ? 5000 : parseInt(config.blockPollingTime, 10);
|
||||
setInterval(
|
||||
function () {
|
||||
coins.forEach(function(coin) {
|
||||
//coin.pool.
|
||||
});
|
||||
},
|
||||
pollingTime
|
||||
);
|
||||
}
|
||||
|
||||
@ -145,8 +145,8 @@ var JobManager = module.exports = function JobManager(options){
|
||||
var headerBigNum = bignum.fromBuffer(headerHash, {endian: 'little', size: 32});
|
||||
|
||||
if (job.target.ge(headerBigNum)){
|
||||
var blockHex = job.serializeBlock(headerBuffer, coinbaseBuffer);
|
||||
_this.emit('blockFound', blockHex);
|
||||
var blockBuf = job.serializeBlock(headerBuffer, coinbaseBuffer);
|
||||
_this.emit('blockFound', blockBuf.toString('hex'));
|
||||
}
|
||||
|
||||
var targetUser = bignum(diffDividend / difficulty);
|
||||
|
||||
22
pool.js
22
pool.js
@ -24,20 +24,25 @@ var pool = module.exports = function pool(coin){
|
||||
_this.stratumServer.broadcastMiningJobs(blockTemplate.getJobParams());
|
||||
}).on('blockFound', function(blockHex){
|
||||
|
||||
if (coin.options.hasSubmitMethod)
|
||||
if (coin.options.hasSubmitMethod) {
|
||||
_this.daemon.cmd('submitblock',
|
||||
[blockHex],
|
||||
function(error, result){
|
||||
|
||||
console.log(JSON.stringify(error));
|
||||
console.log(JSON.stringify(result));
|
||||
console.log("submitblock", JSON.stringify(error), JSON.stringify(result));
|
||||
}
|
||||
);
|
||||
else
|
||||
} else {
|
||||
_this.daemon.cmd('getblocktemplate',
|
||||
[{'mode': 'submit', 'data': blockHex}],
|
||||
function(error, result){
|
||||
|
||||
console.log(JSON.stringify(error));
|
||||
console.log(JSON.stringify(result));
|
||||
console.log("submitblockgetBlockTEmplate", JSON.stringify(error), JSON.stringify(result));
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Connecting to daemon for ' + coin.options.name);
|
||||
@ -132,11 +137,11 @@ var pool = module.exports = function pool(coin){
|
||||
}
|
||||
|
||||
function GetBlockTemplate(callback){
|
||||
console.log("getBlockTemplate");
|
||||
_this.daemon.cmd('getblocktemplate',
|
||||
[{"capabilities": [ "coinbasetxn", "workid", "coinbase/append" ]}],
|
||||
function(error, result){
|
||||
if (error){
|
||||
console.log('getblocktemplate rpc error for ' + coin.options.name);
|
||||
callback(error);
|
||||
}
|
||||
else{
|
||||
@ -146,6 +151,13 @@ var pool = module.exports = function pool(coin){
|
||||
);
|
||||
}
|
||||
|
||||
this.processBlockPolling = function() {
|
||||
GetBlockTemplate(function(error, result) {
|
||||
console.log(JSON.stringify(result));
|
||||
_this.jobManager.newTemplate(result, publicKeyBuffer);
|
||||
});
|
||||
}
|
||||
|
||||
this.processBlockNotify = function(blockHash){
|
||||
if (blockHash !== _this.jobManager.currentJob.rpcData.previousblockhash){
|
||||
GetBlockTemplate(function(error, result){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user