Skip to content

Commit 390cd7e

Browse files
authored
Updated proof_of_work.py
1 parent bbe09d7 commit 390cd7e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

blockchain/proof_of_work.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def proof_of_work(difficulty: int) -> int:
66
"""
77
Simulates a Proof of Work mining process.
88
9-
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
1010
with a specific number of leading zeros (difficulty).
1111
1212
Args:
@@ -20,14 +20,14 @@ def proof_of_work(difficulty: int) -> int:
2020
>>> isinstance(result, int)
2121
True
2222
"""
23-
prefix = "0" * difficulty
23+
prefix = '0' * difficulty
2424
nonce = 0
2525
start = time.time()
2626

2727
while True:
2828
hash_result = hashlib.sha256(f"{nonce}".encode()).hexdigest()
2929
if hash_result.startswith(prefix):
3030
end = time.time()
31-
print(f"Nonce: {nonce}, Hash: {hash_result}, Time: {end - start:.2f}s")
31+
# Removed the print statement
3232
return nonce
3333
nonce += 1

0 commit comments

Comments
 (0)