Spaces:
Running
Running
Husnain
commited on
Commit
•
eea80f1
1
Parent(s):
705c347
⚡ [Enhance] Replace Crypto with hashlib
Browse files- networks/proof_worker.py +10 -6
networks/proof_worker.py
CHANGED
@@ -9,7 +9,10 @@ from constants.headers import OPENAI_GET_HEADERS
|
|
9 |
|
10 |
|
11 |
class ProofWorker:
|
12 |
-
def __init__(self):
|
|
|
|
|
|
|
13 |
self.proof_token_prefix = "gAAAAABwQ8Lk5FbGpA2NcR9dShT6gYjU7VxZ4D"
|
14 |
|
15 |
def get_parse_time(self):
|
@@ -44,14 +47,15 @@ class ProofWorker:
|
|
44 |
hash = hasher.digest().hex()
|
45 |
if hash[:diff_len] <= difficulty:
|
46 |
return "gAAAAAB" + base
|
47 |
-
|
|
|
|
|
|
|
48 |
|
49 |
|
50 |
if __name__ == "__main__":
|
51 |
seed, difficulty = "0.42665582693491433", "05cdf2"
|
52 |
worker = ProofWorker()
|
53 |
proof_token = worker.calc_proof_token(seed, difficulty)
|
54 |
-
|
55 |
-
|
56 |
-
else:
|
57 |
-
print("Failed to generate proof token.")
|
|
|
9 |
|
10 |
|
11 |
class ProofWorker:
|
12 |
+
def __init__(self, difficulty=None, required=False, seed=None):
|
13 |
+
self.difficulty = difficulty
|
14 |
+
self.required = required
|
15 |
+
self.seed = seed
|
16 |
self.proof_token_prefix = "gAAAAABwQ8Lk5FbGpA2NcR9dShT6gYjU7VxZ4D"
|
17 |
|
18 |
def get_parse_time(self):
|
|
|
47 |
hash = hasher.digest().hex()
|
48 |
if hash[:diff_len] <= difficulty:
|
49 |
return "gAAAAAB" + base
|
50 |
+
self.proof_token = (
|
51 |
+
self.proof_token_prefix + base64.b64encode(seed.encode()).decode()
|
52 |
+
)
|
53 |
+
return self.proof_token
|
54 |
|
55 |
|
56 |
if __name__ == "__main__":
|
57 |
seed, difficulty = "0.42665582693491433", "05cdf2"
|
58 |
worker = ProofWorker()
|
59 |
proof_token = worker.calc_proof_token(seed, difficulty)
|
60 |
+
print(f"proof_token: {proof_token}")
|
61 |
+
# python -m networks.proof_worker
|
|
|
|