Skip to content

Commit

Permalink
Modified confirmBlockSubmit to use staticHash of header for better su…
Browse files Browse the repository at this point in the history
…bmission check
  • Loading branch information
aion-Ross committed Apr 4, 2018
1 parent 935e7b7 commit a4519cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = function BlockTemplate(
return header
}

//AION Block header specialization - TO FINISH TOMORROW
//AION Block header specialization
this.serializeHeaderTarget = function(nonce, soln, nTime){

var header = Buffer.alloc(1936)
Expand Down
3 changes: 2 additions & 1 deletion aion_solo_pool/local_modules/stratum-pool/lib/jobManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ var JobManager = module.exports = function JobManager(options){
blockDiff: blockDiffAdjusted,
blockDiffActual: job.difficulty,
blockHash:completeHeaderHash.toString('hex'),
blockHashInvalid: blockHashInvalid
blockHashInvalid: blockHashInvalid,
staticHash: job.rpcData.headerHash
}, blockHex, nTime, nonce, new Buffer(soln.slice(6), 'hex').toString('hex'), job.headerHash);

return {result: true, error: null, blockHash: blockHash};
Expand Down
8 changes: 4 additions & 4 deletions aion_solo_pool/local_modules/stratum-pool/lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ var pool = module.exports = function pool(options, authorizeFn){
//RK - Assume block has been accepted
//Get the new block template after 0.5 sec

CheckBlockAccepted(shareData.height, shareData.blockHash, function(isAccepted){
CheckBlockAccepted(shareData.height, shareData.staticHash, function(isAccepted){
isValidBlock = isAccepted;
emitShare();

Expand All @@ -348,7 +348,7 @@ var pool = module.exports = function pool(options, authorizeFn){
});
};

setTimeout(getBlockTemplateFunction, 500);
setTimeout(getBlockTemplateFunction, 2000);
});

});
Expand Down Expand Up @@ -607,12 +607,12 @@ var pool = module.exports = function pool(options, authorizeFn){



function CheckBlockAccepted(blockHeight, blockHash, callback){
function CheckBlockAccepted(blockHeight, staticHash, callback){
setTimeout(function(){
_this.daemon.cmd('getHeaderByBlockNumber',
[blockHeight],
function(results){
callback(results[0].response && (results[0].response.headerHash === blockHash));
callback(results[0].response && (results[0].response.headerHash === staticHash));
}
);
}, 1000);
Expand Down

0 comments on commit a4519cd

Please sign in to comment.