|
|
|
|
You can see the statistics of your reports to moderators on the "Report to moderator" pages.
|
|
|
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
|
|
|
|
TheArchaeologist
|
|
August 29, 2018, 09:23:46 PM Last edit: August 30, 2018, 09:46:03 AM by TheArchaeologist |
|
The second one is correct. Each block header must hash to a value below the target threshold. For more in-depth documentation you can check the developers guide on proof of work here: https://bitcoin.org/en/developer-guide#proof-of-workUpdate: see below for proof my linked documentation does not match the reality. #1 is correct.
|
Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
|
|
|
odolvlobo
Legendary
Offline
Activity: 4312
Merit: 3214
|
|
August 30, 2018, 02:51:08 AM |
|
It looks to me like the answer is #1. bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params) { bool fNegative; bool fOverflow; arith_uint256 bnTarget;
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
// Check range if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return false;
// Check proof of work matches claimed amount if (UintToArith256(hash) > bnTarget) return false;
return true; }
|
Join an anti-signature campaign: Click ignore on the members of signature campaigns. PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
|
|
|
TheArchaeologist
|
|
August 30, 2018, 06:38:59 AM Last edit: August 30, 2018, 09:42:30 AM by TheArchaeologist |
|
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params) { bool fNegative; bool fOverflow; arith_uint256 bnTarget;
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
// Check range if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return false;
// Check proof of work matches claimed amount if (UintToArith256(hash) > bnTarget) return false;
return true; }
Code doesn't lie So I agree it should be #1 then. Another case where the (official) documentation doesn't project the reality then! Anyhow, learned something again
|
Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
|
|
|
mocacinno
Legendary
Offline
Activity: 3388
Merit: 4922
https://merel.mobi => buy facemasks with BTC/LTC
|
|
August 30, 2018, 06:43:52 AM |
|
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params) { bool fNegative; bool fOverflow; arith_uint256 bnTarget;
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
// Check range if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return false;
// Check proof of work matches claimed amount if (UintToArith256(hash) > bnTarget) return false;
return true; }
Code doesn't lie So I agree it should be #2 then. Another case where the (official) documentation doesn't project the reality then! Anyhow, learned something again If the hash is bigger than the target, return false.. So if the hash is smaller than OR EQUAL TO the target, true is returned... #1 is correct (if i'm not mistaking)
|
|
|
|
TheArchaeologist
|
|
August 30, 2018, 07:50:48 AM Last edit: August 30, 2018, 09:43:00 AM by TheArchaeologist Merited by ABCbits (4), achow101 (3) |
|
If the hash is bigger than the target, return false.. So if the hash is smaller than OR EQUAL TO the target, true is returned... #1 is correct (if i'm not mistaking)
Let's break this down to a simple example: Target = 10
Scenario A: Check value 9 Scenario B: Check value 10 Scenario C: Check value 11
Code: return = true;
#Scenario A: if (9 > 10 ) return false; #Scenario A: returns ->true
#Scenario B: if (10 > 10 ) return false; #Scenario B: returns -> true
#Scenario C: if (11 > 10) return false; #Scenario C: returns -> false
Conclusion: EQAUL TO (as in scenario B) returns true, meaning it is accepted. In other words: #1 is the correct one.
|
Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
|
|
|
waxload
Newbie
Offline
Activity: 7
Merit: 0
|
|
August 30, 2018, 08:34:43 AM |
|
Hi,
Actually it seems that the wiki have some errors : and a lot.
Definitely the second answer is correct ! From my past experience in mining sha-256 ...hash need to be greater to be accepted and if it is lower you try again and every re targeting period the difficulty increase.
|
|
|
|
bob123
Legendary
Offline
Activity: 1624
Merit: 2481
|
|
August 30, 2018, 09:03:37 AM |
|
From my past experience in mining sha-256 ...hash need to be greater to be accepted and if it is lower you try again and every re targeting period the difficulty increase.
You obviously don't have any experience at all. The hash needs to be LOWER or EQUAL TO the target. This has been discussed in this thread and should be clear if you have completely read it. The difficulty also does NOT increase each 2016 blocks. This depends on time it took to mine these blocks. Overall, the difficulty rises. But there also were shorter streaks where the difficulty and hashrate was dropping over multiple periods.
|
|
|
|
mocacinno
Legendary
Offline
Activity: 3388
Merit: 4922
https://merel.mobi => buy facemasks with BTC/LTC
|
|
August 30, 2018, 09:40:20 AM |
|
If the hash is bigger than the target, return false.. So if the hash is smaller than OR EQUAL TO the target, true is returned... #1 is correct (if i'm not mistaking)
Let's break this down to a simple example: Target = 10
Scenario A: Check value 9 Scenario B: Check value 10 Scenario C: Check value 11
Code return = true;
#Scenario A: if (9 > 10 ) return false; #Scenario A: returns ->true
#Scenario B: if (10 > 10 ) return false; #Scenario B: returns -> true
#Scenario C: if (11 > 10) return false; #Scenario B: returns -> false
Conclusion: EQAUL TO (as in scenario B) returns true, meaning it is accepted. In other words: #2 is the correct one. I'm on my employer's laptop, which only has php installed, so i wrote this analogy with the code: <?php $target = 10; $hash = $target - 2; $end = $target + 2;
while ($hash < $end) { echo "testing hash $hash vs target $target => "; if ($hash > $target) { echo "POW does not match claimed ammount\n"; } else { echo "OK!\n"; } $hash++; } ?>
response: testing hash 8 vs target 10 => OK! testing hash 9 vs target 10 => OK! testing hash 10 vs target 10 => OK! testing hash 11 vs target 10 => POW does not match claimed ammount
Since the OP was: I still think #1 is correct, the function will return true if the hash is lower than or equal to the target EDIT: after re-reading your reply and noticing your conclusion was the same as mine: the hash has to be lower than or equal to, i just realised one of us is just misinterpreting the OP... We both conclude that hashes lower than or equal to the target are fine... It's just that my interpretation of sollution one is exactly correct, while my interpretation of sollution 2 says that only hashes lower than the target are true (which is not correct if i'm not mistaking)...
|
|
|
|
TheArchaeologist
|
|
August 30, 2018, 09:50:32 AM |
|
I still think #1 is correct, the function will return true if the hash is lower than or equal to the target We came to the same conclusion I mixed up by claiming #2 was right while delivering proof #1 was right (just as you did). I edited my post to match the right number. End conclusion: We agree #1 is the correct one. We even both delivered examples as proof
|
Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
|
|
|
bob123
Legendary
Offline
Activity: 1624
Merit: 2481
|
End conclusion: We agree #1 is the correct one. We even both delivered examples as proof Note: An example can NEVER proof a theory. It can only disprove one. The real prove is this: bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params) { ~snip~ // Check proof of work matches claimed amount if (UintToArith256(hash) > bnTarget) return false; return true; }
The statement is: Hash > Target THEN Not valid If we negate that statement (to match the statement 'valid'): Hash <= Target THEN ValidAnd this matches #1 from OP.
|
|
|
|
|