PoW共识机制

转载自某花钱的网课
PoW共识
PoW共识


#!/usr/bin/env python
import hashlib

def main():
    base_string = "geekbang"
    nonce = 10000
    count = 0
    while True:
        target_string = base_string + str(nonce)
        pow_hash = hashlib.sha256(target_string).hexdigest()
        count = count + 1
        if pow_hash.startswith("0000"):
            print pow_hash
            print "nonce: %s  scan times: %s" % (nonce, count)
            break
        nonce = nonce + 1

if __name__ == '__main__':
    main()

PoW共识

# 前 4 位是 0
0000250248f805c558bc28864a6bb6bf0c244d836a6b1a0c5078987aa219a404
nonce: 68828  scan times: 58829
# 前 5 位是 0
0000067fc247325064f685c32f8a079584b19106c5228b533f10c775638d454c
nonce: 1241205  scan times: 1231206
# 前 7 位是 0
00000003f41b126ec689b1a2da9e7d46d13d0fd1bece47983d53c5d32eb4ac90
nonce: 165744821  scan times: 165734822

PoW共识

相关文章:

  • 2021-12-04
  • 2021-11-21
  • 2021-05-29
  • 2021-10-09
  • 2021-08-07
  • 2021-06-12
  • 2022-02-11
  • 2021-06-25
猜你喜欢
  • 2019-08-02
  • 2021-06-20
  • 2021-10-03
  • 2021-10-12
  • 2022-02-17
  • 2021-08-18
相关资源
相似解决方案