Spaces:
Running
Running
Husnain
commited on
Under Testing...
Browse files- networks/proof_worker.py +5 -7
networks/proof_worker.py
CHANGED
@@ -35,7 +35,7 @@ class ProofWorker:
|
|
35 |
OPENAI_GET_HEADERS["User-Agent"],
|
36 |
]
|
37 |
|
38 |
-
def calc_proof_token(self, seed: str, difficulty: str):
|
39 |
config = self.get_config()
|
40 |
diff_len = len(difficulty) // 2
|
41 |
for i in range(100000):
|
@@ -47,15 +47,13 @@ class ProofWorker:
|
|
47 |
hash = hasher.digest().hex()
|
48 |
if hash[:diff_len] <= difficulty:
|
49 |
return "gAAAAAB" + base
|
50 |
-
|
51 |
-
|
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
|
|
|
35 |
OPENAI_GET_HEADERS["User-Agent"],
|
36 |
]
|
37 |
|
38 |
+
def calc_proof_token(self, seed: str, difficulty: str, user_id: str):
|
39 |
config = self.get_config()
|
40 |
diff_len = len(difficulty) // 2
|
41 |
for i in range(100000):
|
|
|
47 |
hash = hasher.digest().hex()
|
48 |
if hash[:diff_len] <= difficulty:
|
49 |
return "gAAAAAB" + base
|
50 |
+
|
51 |
+
raise RuntimeError("Proof token couldn't be generated")
|
|
|
|
|
52 |
|
53 |
|
54 |
if __name__ == "__main__":
|
55 |
seed, difficulty = "0.42665582693491433", "05cdf2"
|
56 |
+
user_id = "Niansuh"
|
57 |
worker = ProofWorker()
|
58 |
+
proof_token = worker.calc_proof_token(seed, difficulty, user_id)
|
59 |
print(f"proof_token: {proof_token}")
|
|