-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple instance #20
base: master
Are you sure you want to change the base?
Conversation
LGMT, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed more in depth the atomicity logic of the duplicate solution corner case, and it could be improved.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it more relevant to be from a different worker address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello
-_- |
No description provided.