Conversation
|
LGMT, thanks! |
test/shareProcessorTest.js
Outdated
|
|
||
| var share1 = {job: {fromGroup: 0, toGroup: 1}, foundBlock: false, blockHash: 'hash1', difficulty: 1, workerAddress: 'miner1'}; | ||
| var share2 = {job: {fromGroup: 0, toGroup: 1}, foundBlock: false, blockHash: 'hash2', difficulty: 2, workerAddress: 'miner1'}; | ||
| var invalidShare = {job: {fromGroup: 0, toGroup: 1}, foundBlock: false, blockHash: 'hash1', difficulty: 3, workerAddress: 'miner1'}; |
There was a problem hiding this comment.
Shouldn't it more relevant to be from a different worker address?
There was a problem hiding this comment.
Now we check if a share is duplicated based on hash, but it's good for testing, thanks.
| var newKey = _this.roundKey(fromGroup, toGroup, blockHash); | ||
| var blockWithTs = blockHash + ':' + currentMs.toString(); | ||
|
|
||
| redisTx.rename(currentRound, newKey); |
There was a problem hiding this comment.
renamenx should probably be used here, otherwise in case of found block sent with delay (but still not expired) by one worker, the sharecache key would have been deleted and the shares for the block overwritten by new currentRound.
There was a problem hiding this comment.
Great catch, thanks, the remaining commands will continue to execute even if renamenx failed in redis transaction, so my thought is that we can use set hash true ex expiryPeriod nx to check if the share is duplicated, which expiryPeriod > jobExpiryPeriod, how do you think?
|
|
||
| redisTx.rename(currentRound, newKey); | ||
| redisTx.sadd(pendingBlocksKey, blockWithTs); | ||
| redisTx.hset(foundBlocksKey, blockHash, share.workerAddress) |
There was a problem hiding this comment.
hsetnx should be used here, so that "paternity" of the block is kept to the first worker who submitted it (in case of same corner case than above)
|
-_- |
No description provided.