py-near 1.1.42__py3-none-any.whl → 1.1.43__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
@@ -93,28 +93,29 @@ class JsonProvider(object):
|
|
93
93
|
"params": {"finality": "final"},
|
94
94
|
"id": 1,
|
95
95
|
}
|
96
|
-
async with
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
96
|
+
async with aiohttp.ClientSession() as session:
|
97
|
+
async with session.post(rpc_addr, json=data) as r:
|
98
|
+
if r.status == 200:
|
99
|
+
data = json.loads(await r.text())["result"]
|
100
|
+
if data["sync_info"]["syncing"]:
|
101
|
+
last_block_ts = datetime.datetime.fromisoformat(
|
102
|
+
data["sync_info"]["latest_block_time"]
|
103
|
+
)
|
104
|
+
diff = (
|
105
|
+
datetime.datetime.utcnow().timestamp()
|
106
|
+
- last_block_ts.timestamp()
|
107
|
+
)
|
108
|
+
is_syncing = diff > 60
|
109
|
+
else:
|
110
|
+
is_syncing = False
|
111
|
+
if is_syncing:
|
112
|
+
logger.error(f"Remove async RPC : {rpc_addr} ({diff})")
|
113
|
+
continue
|
114
|
+
available_rpcs.append(rpc_addr)
|
108
115
|
else:
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
continue
|
113
|
-
available_rpcs.append(rpc_addr)
|
114
|
-
else:
|
115
|
-
logger.error(
|
116
|
-
f"Remove rpc because of error {r.status}: {rpc_addr}"
|
117
|
-
)
|
116
|
+
logger.error(
|
117
|
+
f"Remove rpc because of error {r.status}: {rpc_addr}"
|
118
|
+
)
|
118
119
|
except Exception as e:
|
119
120
|
if rpc_addr in self._available_rpcs:
|
120
121
|
logger.error(f"Remove rpc: {e}")
|
@@ -137,23 +138,24 @@ class JsonProvider(object):
|
|
137
138
|
if "@" in rpc_call_addr:
|
138
139
|
auth_key = rpc_call_addr.split("//")[1].split("@")[0]
|
139
140
|
rpc_call_addr = rpc_call_addr.replace(auth_key + "@", "")
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
"
|
154
|
-
|
141
|
+
async with aiohttp.ClientSession() as session:
|
142
|
+
r = await session.post(
|
143
|
+
rpc_call_addr,
|
144
|
+
json=j,
|
145
|
+
timeout=self._timeout,
|
146
|
+
headers={
|
147
|
+
"Referer": "https://tgapp.herewallet.app",
|
148
|
+
"Authorization": f"Bearer {auth_key}",
|
149
|
+
}, # NEAR RPC requires Referer header
|
150
|
+
)
|
151
|
+
if r.status == 200:
|
152
|
+
return json.loads(await r.text())
|
153
|
+
return {
|
154
|
+
"error": {
|
155
|
+
"cause": {"name": "RPC_ERROR", "message": f"Status: {r.status}"},
|
156
|
+
"data": await r.text(),
|
157
|
+
}
|
155
158
|
}
|
156
|
-
}
|
157
159
|
|
158
160
|
if broadcast or threshold:
|
159
161
|
pending = [
|
@@ -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=gNYPBWoYIO1Tqj2aPvBlJUrFvUZtCIo6o19o9ibOFxo,15986
|
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.43.dist-info/LICENSE,sha256=I_GOA9xJ35FiL-KnYXZJdATkbO2KcV2dK2enRGVxzKM,1023
|
27
|
+
py_near-1.1.43.dist-info/METADATA,sha256=3xDsCOdQv1EbiwaUX4pItm0bcgqm9X5xF_3-ifSUWfM,4713
|
28
|
+
py_near-1.1.43.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
29
|
+
py_near-1.1.43.dist-info/RECORD,,
|
File without changes
|
File without changes
|