-
Notifications
You must be signed in to change notification settings - Fork 854
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
Question: host does the blockHasher code works? #154
Comments
@zone117x @foxer666 @devnull-ed Guys, can someone explain? |
This is an interesting case. I don't really remember this code (it was 4 years ago), but after looking through it I think it works because of: The full block hash is not the hash algorithm that matters. Its the block header hash which miners calculate and which most altcoins even bother changing. See here where block header hash is used for difficulty validation: node-stratum-pool/lib/jobManager.js Line 225 in 4f298c3
The full block hex is what is gets submitted to the daemon and the daemon does its own hashing and validation on the block, see here: Line 322 in 4f298c3
The full block hash is only used to validate that the block was accepted via the daemon rpc, see here: Line 597 in 4f298c3
From what I can remember - most altcoins don't change the hash algorithm used in any of the other areas. Which is why that switch case statement is very selective with which coins it uses a different full block hash algo for. Apparently it is/was so rare for altcoins to change it that it was never necessary to add that configuration explicitly to the coin.json options. So in other words - almost all altcoins use sha256d for hashing everything except for the block header. |
I found this block of code and was very surprised when it works correctly.
Can somebody explain me why this works?
default
case in switch-case block is unreachable code because ofbreak
s lack. Which means that by default block header's hashing by SHA256D algo. Is this what it was supposed to be? ForIf we choose, for example,DOGE
which usesscrypt
(POW) then in that switch-case we'll fall intosha1
case, which seems illogical.The text was updated successfully, but these errors were encountered: