Skip to content

Commit bd89e97

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 374cbc2 commit bd89e97

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

blockchain/proof_of_work.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import hashlib
22
import time
33

4+
45
def proof_of_work(difficulty: int) -> int:
56
"""
67
Simulates a Proof of Work mining process.
78
8-
The miner must find a nonce such that the hash of the nonce starts
9+
The miner must find a nonce such that the hash of the nonce starts
910
with a specific number of leading zeros (difficulty).
1011
1112
Args:
@@ -19,10 +20,10 @@ def proof_of_work(difficulty: int) -> int:
1920
>>> isinstance(result, int)
2021
True
2122
"""
22-
prefix = '0' * difficulty
23+
prefix = "0" * difficulty
2324
nonce = 0
2425
start = time.time()
25-
26+
2627
while True:
2728
hash_result = hashlib.sha256(f"{nonce}".encode()).hexdigest()
2829
if hash_result.startswith(prefix):

0 commit comments

Comments
 (0)