py-near 1.1.43__py3-none-any.whl → 1.1.45__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py_near/providers.py
CHANGED
@@ -61,10 +61,9 @@ class JsonProvider(object):
|
|
61
61
|
self._last_rpc_addr_check = 0
|
62
62
|
self.allow_broadcast = allow_broadcast
|
63
63
|
self._timeout = timeout
|
64
|
-
self.session = aiohttp.ClientSession()
|
65
64
|
|
66
65
|
async def shutdown(self):
|
67
|
-
|
66
|
+
pass
|
68
67
|
|
69
68
|
async def check_available_rpcs(self):
|
70
69
|
if (
|
@@ -81,7 +80,8 @@ class JsonProvider(object):
|
|
81
80
|
await asyncio.sleep(3)
|
82
81
|
|
83
82
|
if not self._available_rpcs:
|
84
|
-
|
83
|
+
self._available_rpcs = self._rpc_addresses.copy()
|
84
|
+
logger.error("All RPCs are async, reset to default list")
|
85
85
|
|
86
86
|
async def _check_available_rpcs(self):
|
87
87
|
available_rpcs = []
|
@@ -93,8 +93,15 @@ class JsonProvider(object):
|
|
93
93
|
"params": {"finality": "final"},
|
94
94
|
"id": 1,
|
95
95
|
}
|
96
|
+
auth_key = "py-near"
|
97
|
+
if "@" in rpc_addr:
|
98
|
+
auth_key = rpc_addr.split("//")[1].split("@")[0]
|
99
|
+
rpc_addr = rpc_addr.replace(auth_key + "@", "")
|
96
100
|
async with aiohttp.ClientSession() as session:
|
97
|
-
async with session.post(rpc_addr, json=data
|
101
|
+
async with session.post(rpc_addr, json=data, headers={
|
102
|
+
"Referer": "https://tgapp.herewallet.app",
|
103
|
+
"Authorization": f"Bearer {auth_key}",
|
104
|
+
}) as r:
|
98
105
|
if r.status == 200:
|
99
106
|
data = json.loads(await r.text())["result"]
|
100
107
|
if data["sync_info"]["syncing"]:
|
@@ -119,6 +126,7 @@ class JsonProvider(object):
|
|
119
126
|
except Exception as e:
|
120
127
|
if rpc_addr in self._available_rpcs:
|
121
128
|
logger.error(f"Remove rpc: {e}")
|
129
|
+
logger.error(f"Rpc check error: {e}")
|
122
130
|
self._available_rpcs = available_rpcs
|
123
131
|
|
124
132
|
@staticmethod
|
@@ -163,6 +171,7 @@ class JsonProvider(object):
|
|
163
171
|
]
|
164
172
|
|
165
173
|
responses = []
|
174
|
+
correct_responses = []
|
166
175
|
while pending and len(pending):
|
167
176
|
done, pending = await asyncio.wait(
|
168
177
|
pending, return_when=asyncio.FIRST_COMPLETED
|
@@ -175,7 +184,7 @@ class JsonProvider(object):
|
|
175
184
|
responses.append(result)
|
176
185
|
except Exception as e:
|
177
186
|
logger.warning(e)
|
178
|
-
if responses:
|
187
|
+
if responses and threshold:
|
179
188
|
array = [hash(json.dumps(x)) for x in responses]
|
180
189
|
most_frequent_element = self.most_frequent_by_hash(array)
|
181
190
|
correct_responses = [
|
@@ -185,6 +194,7 @@ class JsonProvider(object):
|
|
185
194
|
for task in pending:
|
186
195
|
task.cancel()
|
187
196
|
return most_frequent_element
|
197
|
+
raise RpcEmptyResponse(f"Threshold not reached: {len(correct_responses)}/{threshold}")
|
188
198
|
else:
|
189
199
|
for rpc_addr in self._available_rpcs:
|
190
200
|
try:
|
@@ -20,10 +20,10 @@ py_near/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
20
20
|
py_near/exceptions/exceptions.py,sha256=DEFipaAHm0y7oCuN2QKzHsiQvUTUQVl-Ce36Ag7n7hs,5509
|
21
21
|
py_near/exceptions/provider.py,sha256=K-wexgjPJ8sw42JePwaP7R5dJEIn9DoFJRvVcURsx6s,7718
|
22
22
|
py_near/models.py,sha256=GZQD1TKGWlwqsJsKRXrVNBjCdAIpk7GQypU-QOtAPFs,11533
|
23
|
-
py_near/providers.py,sha256=
|
23
|
+
py_near/providers.py,sha256=Z7Zzcor-B-jMgLoz2Injmxe9LhdszBtCoC2zYbTScJQ,16557
|
24
24
|
py_near/transactions.py,sha256=QAXegv2JpKISk92NaChtIH6-QPHrcWbrwdKH_lH4TsU,3186
|
25
25
|
py_near/utils.py,sha256=FirRH93ydH1cwjn0-sNrZeIn3BRD6QHedrP2VkAdJ6g,126
|
26
|
-
py_near-1.1.
|
27
|
-
py_near-1.1.
|
28
|
-
py_near-1.1.
|
29
|
-
py_near-1.1.
|
26
|
+
py_near-1.1.45.dist-info/LICENSE,sha256=I_GOA9xJ35FiL-KnYXZJdATkbO2KcV2dK2enRGVxzKM,1023
|
27
|
+
py_near-1.1.45.dist-info/METADATA,sha256=wD-DlYJ16hIJ6u49RWcRp8rb_Kn7-kHp8VVdRo7vGII,4713
|
28
|
+
py_near-1.1.45.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
29
|
+
py_near-1.1.45.dist-info/RECORD,,
|
File without changes
|
File without changes
|