Skip to content

Commit d6ab438

Browse files
authored
Updated proof_of_work.py
1 parent 5e70415 commit d6ab438

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

blockchain/proof_of_work.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import hashlib
22
import time
33

4-
54
def proof_of_work(difficulty: int) -> int:
65
"""
76
Simulates a Proof of Work mining process.
87
9-
The miner must find a nonce such that the hash of the nonce starts
10-
with a specific number of leading zeros (difficulty)
8+
The miner must find a nonce such that the hash of the nonce starts
9+
with a specific number of leading zeros (difficulty).
1110
1211
Args:
13-
difficulty (int): The number of leading zeros required in the hash.
12+
difficulty (int): The number of leading zeros required in the hash.
13+
1414
Returns:
15-
int: The nonce value that solves the puzzle.
15+
int: The nonce value that solves the puzzle.
1616
1717
Example:
18-
>>> result = proof_of_work(2) # Difficulty of 2 should be fast
19-
>>> isinstance(result, int)
20-
True
18+
>>> result = proof_of_work(2) # Difficulty of 2 should be fast
19+
>>> isinstance(result, int)
20+
True
2121
"""
22-
prefix = "0" * difficulty
22+
prefix = '0' * difficulty
2323
nonce = 0
2424
start = time.time() # Timing starts
2525

0 commit comments

Comments
 (0)