-
-
Save bb111189/3c3cc4b16b09913d157d55aa85044921 to your computer and use it in GitHub Desktop.
Zilliqa Difficulty Calculations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_boundary(diff): | |
b = ["1"] * 256 | |
for i in range(diff): | |
b[i] = "0" | |
return int("".join(b), 2) | |
def to_hashrate(diff): | |
boundary = to_boundary(diff) | |
result = pow(2, 256) / float(boundary) | |
return result | |
def abbrev_hashrate(rate): | |
quantifiers = (("Gh", 1000000000.0), ("Mh", 1000000.0), ("Kh", 1000.0)) | |
for quant, divisor in quantifiers: | |
divided = rate/divisor | |
if divided > 1: | |
return "%.f %s" % (divided, quant) | |
return "%d H" % rate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment