Added "emitInvalidBlockHashes" option for those in MPOS mode that require it
This commit is contained in:
parent
78f6a8c2e6
commit
68f9fb566c
18
README.md
18
README.md
@ -150,6 +150,9 @@ var pool = Stratum.createPool({
|
|||||||
detects those and disconnects them. */
|
detects those and disconnects them. */
|
||||||
"connectionTimeout": 600, //Remove workers that haven't been in contact for this many seconds
|
"connectionTimeout": 600, //Remove workers that haven't been in contact for this many seconds
|
||||||
|
|
||||||
|
/* Sometimes you want the block hashes even for shares that aren't block candidates. */
|
||||||
|
"emitInvalidBlockHashes": false,
|
||||||
|
|
||||||
/* If a worker is submitting a good deal of invalid shares we can temporarily ban them to
|
/* If a worker is submitting a good deal of invalid shares we can temporarily ban them to
|
||||||
reduce system/network load. Also useful to fight against flooding attacks. */
|
reduce system/network load. Also useful to fight against flooding attacks. */
|
||||||
"banning": {
|
"banning": {
|
||||||
@ -248,11 +251,14 @@ Listen to pool events
|
|||||||
height: 443795, //block height
|
height: 443795, //block height
|
||||||
networkDifficulty: 3349 //network difficulty for this block
|
networkDifficulty: 3349 //network difficulty for this block
|
||||||
|
|
||||||
//solution is set if block was found
|
//AAK the block solution - set if block was found
|
||||||
solution: '110c0447171ad819dd181216d5d80f41e9218e25d833a2789cb8ba289a52eee4',
|
blockHash: '110c0447171ad819dd181216d5d80f41e9218e25d833a2789cb8ba289a52eee4',
|
||||||
|
|
||||||
//tx is the coinbase transaction hash from the block
|
//Exists if "emitInvalidBlockHashes" is set to true
|
||||||
tx: '41bb22d6cc409f9c0bae2c39cecd2b3e3e1be213754f23d12c5d6d2003d59b1d,
|
blockHashInvalid: '110c0447171ad819dd181216d5d80f41e9218e25d833a2789cb8ba289a52eee4'
|
||||||
|
|
||||||
|
//txHash is the coinbase transaction hash from the block
|
||||||
|
txHash: '41bb22d6cc409f9c0bae2c39cecd2b3e3e1be213754f23d12c5d6d2003d59b1d,
|
||||||
|
|
||||||
error: 'low share difficulty' //set if share is rejected for some reason
|
error: 'low share difficulty' //set if share is rejected for some reason
|
||||||
*/
|
*/
|
||||||
@ -262,8 +268,8 @@ pool.on('share', function(isValidShare, isValidBlock, data){
|
|||||||
console.log('Block found');
|
console.log('Block found');
|
||||||
else if (isValidShare)
|
else if (isValidShare)
|
||||||
console.log('Valid share submitted');
|
console.log('Valid share submitted');
|
||||||
else if (data.solution)
|
else if (data.blockHash)
|
||||||
console.log('We thought a block solution was found but it was rejected by the daemon');
|
console.log('We thought a block was found but it was rejected by the daemon');
|
||||||
else
|
else
|
||||||
console.log('Invalid share submitted')
|
console.log('Invalid share submitted')
|
||||||
|
|
||||||
|
|||||||
@ -178,6 +178,7 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
|||||||
var headerHash = hashDigest(headerBuffer, nTimeInt);
|
var headerHash = hashDigest(headerBuffer, nTimeInt);
|
||||||
var headerBigNum = bignum.fromBuffer(headerHash, {endian: 'little', size: 32});
|
var headerBigNum = bignum.fromBuffer(headerHash, {endian: 'little', size: 32});
|
||||||
|
|
||||||
|
var blockHashInvalid;
|
||||||
var blockHash;
|
var blockHash;
|
||||||
var blockHex;
|
var blockHex;
|
||||||
|
|
||||||
@ -188,6 +189,9 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
|||||||
blockHash = util.reverseBuffer(util.sha256d(headerBuffer)).toString('hex');
|
blockHash = util.reverseBuffer(util.sha256d(headerBuffer)).toString('hex');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (options.emitInvalidBlockHashes)
|
||||||
|
blockHashInvalid = util.reverseBuffer(util.sha256d(headerBuffer)).toString('hex');
|
||||||
|
|
||||||
var targetUser = maxDifficulty.div(difficulty);
|
var targetUser = maxDifficulty.div(difficulty);
|
||||||
if (headerBigNum.gt(targetUser)){
|
if (headerBigNum.gt(targetUser)){
|
||||||
//Check if share matched a previous difficulty from before vardiff retarget
|
//Check if share matched a previous difficulty from before vardiff retarget
|
||||||
@ -202,20 +206,6 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!blockHex) {
|
|
||||||
_this.emit('debugBlockShare',
|
|
||||||
{
|
|
||||||
'extraNonce1': extraNonce1,
|
|
||||||
'extraNonce2': extraNonce2,
|
|
||||||
'nTime': nTime,
|
|
||||||
'nonce': nonce,
|
|
||||||
'headerBuffer': headerBuffer.toString('hex'),
|
|
||||||
'headerHash': headerHash.toString('hex'),
|
|
||||||
'blockHex': blockHex,
|
|
||||||
'blockHash': blockHash
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_this.emit('share', {
|
_this.emit('share', {
|
||||||
job: jobId,
|
job: jobId,
|
||||||
@ -225,10 +215,12 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
|||||||
height: job.rpcData.height,
|
height: job.rpcData.height,
|
||||||
reward: job.rpcData.coinbasevalue,
|
reward: job.rpcData.coinbasevalue,
|
||||||
networkDifficulty : job.difficulty.toString(),
|
networkDifficulty : job.difficulty.toString(),
|
||||||
solution: blockHash
|
blockHash: blockHash,
|
||||||
|
blockHashInvalid: blockHashInvalid
|
||||||
|
|
||||||
}, blockHex);
|
}, blockHex);
|
||||||
|
|
||||||
return {result: true, error: null, solution: blockHash};
|
return {result: true, error: null, blockHash: blockHash};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
JobManager.prototype.__proto__ = events.EventEmitter.prototype;
|
JobManager.prototype.__proto__ = events.EventEmitter.prototype;
|
||||||
|
|||||||
@ -289,9 +289,9 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||||||
emitShare();
|
emitShare();
|
||||||
else{
|
else{
|
||||||
SubmitBlock(blockHex, function(){
|
SubmitBlock(blockHex, function(){
|
||||||
CheckBlockAccepted(shareData.solution, function(isAccepted, tx){
|
CheckBlockAccepted(shareData.blockHash, function(isAccepted, tx){
|
||||||
isValidBlock = isAccepted;
|
isValidBlock = isAccepted;
|
||||||
shareData.tx = tx;
|
shareData.txHash = tx;
|
||||||
emitShare();
|
emitShare();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user