Title: Calculate Hash Target and Probability in PHP Post by: mizerydearia on July 17, 2010, 04:37:09 AM I am trying to prepare PHP code to calculate exact value for Hash Target similar as to displayed at http://www.alloscomp.com/bitcoin/calculator.php (currently: 1.48501965484E+65).
Can someone help me to refine my code? http://jsonrpcphp.org/?page=download&lang=en Calculate current hash target: Code: <? Calculate probability: Code: <? Title: Re: Calculate Hash Target in PHP Post by: Insti on July 17, 2010, 08:53:58 AM The difficulty value is derived from the current target.
You can find the current target by "grep"ing 'After' in the debug.log Edit: Oh ok, you already know that, nevermind. Title: Re: Calculate Hash Target and Probability in PHP Post by: theymos on July 17, 2010, 11:41:22 PM This is how I do probability per hash:
Code: $hash=$hextarget; Then you do 1/$probability to get average number of hashes. Divide this by the number of hashes you're getting per second to get the number of seconds. You can calculate the target like this: Code: 26959535291011309493156476344723991336010898738574164086137773096960/difficulty I search debug.log to get the target, but the result of the last retarget seems to be less accurate than the calculation above. I'm not sure why this is. Maybe the code changed. (Edit: I now think that this is just an artifact from the "nBits" decompression.) Title: Re: Calculate Hash Target and Probability in PHP Post by: lachesis on July 23, 2010, 01:15:51 AM "Difficulty" is the number returned by getDifficulty. (The huge number is the maximum target, which getDifficulty is based on.) This calculation is not exact. The difficulty is based on the *minimum* target, and this target is generated rather inexactly as 00000000ffff000000000000000... (eight 0s, four Fs, 0 to taste :D)I search debug.log to get the target, but the result of the last retarget seems to be less accurate than the calculation above. I'm not sure why this is. Maybe the code changed. (Edit: I now think that this is just an artifact from the "nBits" decompression.) Title: Re: Calculate Hash Target and Probability in PHP Post by: theymos on July 23, 2010, 02:25:42 AM The difficulty is based on the *minimum* target, and this target is generated rather inexactly as 00000000ffff000000000000000... (eight 0s, four Fs, 0 to taste :D) No. That target (which I included in decimal in my second formula) is the maximum allowed target. The target is lowered to increase difficulty. The highest target is the lowest difficulty. This is because the probability of winning with one hash is target/max. Reducing target reduces the probability of winning. |