py-near 1.1.24__py3-none-any.whl → 1.1.26__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/account.py +3 -0
- py_near/providers.py +36 -28
- {py_near-1.1.24.dist-info → py_near-1.1.26.dist-info}/METADATA +2 -2
- {py_near-1.1.24.dist-info → py_near-1.1.26.dist-info}/RECORD +6 -6
- {py_near-1.1.24.dist-info → py_near-1.1.26.dist-info}/LICENSE +0 -0
- {py_near-1.1.24.dist-info → py_near-1.1.26.dist-info}/WHEEL +0 -0
py_near/account.py
CHANGED
py_near/providers.py
CHANGED
@@ -75,31 +75,35 @@ class JsonProvider(object):
|
|
75
75
|
available_rpcs = []
|
76
76
|
for rpc_addr in self._rpc_addresses:
|
77
77
|
try:
|
78
|
+
data = {
|
79
|
+
"jsonrpc": "2.0",
|
80
|
+
"method": "status",
|
81
|
+
"params": {"finality": "final"},
|
82
|
+
"id": 1,
|
83
|
+
}
|
78
84
|
async with aiohttp.ClientSession() as session:
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
85
|
+
async with session.post(rpc_addr, json=data) as r:
|
86
|
+
if r.status == 200:
|
87
|
+
data = json.loads(await r.text())['result']
|
88
|
+
if data["sync_info"]["syncing"]:
|
89
|
+
last_block_ts = datetime.datetime.fromisoformat(
|
90
|
+
data["sync_info"]["latest_block_time"]
|
91
|
+
)
|
92
|
+
diff = (
|
93
|
+
datetime.datetime.utcnow().timestamp()
|
94
|
+
- last_block_ts.timestamp()
|
95
|
+
)
|
96
|
+
is_syncing = diff > 60
|
97
|
+
else:
|
98
|
+
is_syncing = False
|
99
|
+
if is_syncing:
|
100
|
+
logger.error(f"Remove async RPC : {rpc_addr} ({diff})")
|
101
|
+
continue
|
102
|
+
available_rpcs.append(rpc_addr)
|
93
103
|
else:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
continue
|
98
|
-
available_rpcs.append(rpc_addr)
|
99
|
-
else:
|
100
|
-
logger.error(
|
101
|
-
f"Remove rpc because of error {r.status}: {rpc_addr}"
|
102
|
-
)
|
104
|
+
logger.error(
|
105
|
+
f"Remove rpc because of error {r.status}: {rpc_addr}"
|
106
|
+
)
|
103
107
|
except Exception as e:
|
104
108
|
if rpc_addr in self._available_rpcs:
|
105
109
|
logger.error(f"Remove rpc: {e}")
|
@@ -208,12 +212,16 @@ class JsonProvider(object):
|
|
208
212
|
await self.check_available_rpcs()
|
209
213
|
for rpc_addr in self._available_rpcs:
|
210
214
|
try:
|
215
|
+
data = {
|
216
|
+
"jsonrpc": "2.0",
|
217
|
+
"method": "status",
|
218
|
+
"params": {"finality": "final"},
|
219
|
+
"id": 1,
|
220
|
+
}
|
211
221
|
async with aiohttp.ClientSession() as session:
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
if r.status == 200:
|
216
|
-
return json.loads(await r.text())
|
222
|
+
async with session.post(rpc_addr, json=data) as r:
|
223
|
+
if r.status == 200:
|
224
|
+
return json.loads(await r.text())['result']
|
217
225
|
except (
|
218
226
|
ClientResponseError,
|
219
227
|
ClientConnectorError,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: py-near
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.26
|
4
4
|
Summary: Pretty simple and fully asynchronous framework for working with NEAR blockchain
|
5
5
|
Author: pvolnov
|
6
6
|
Author-email: petr@herewallet.app
|
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
15
15
|
Requires-Dist: aiohttp (>=3.7.4,<4.0.0)
|
16
|
-
Requires-Dist:
|
16
|
+
Requires-Dist: ed26519 (>=1.5,<2.0)
|
17
17
|
Requires-Dist: py-near-primitives (>=0.2.3,<0.3.0)
|
18
18
|
Description-Content-Type: text/markdown
|
19
19
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
py_near/__init__.py,sha256=t5fAxjaU8dN8xpQR2vz0ZGhfTkdVy2RCbkhJhZFglk4,50
|
2
|
-
py_near/account.py,sha256=
|
2
|
+
py_near/account.py,sha256=sw5bqGUFFOkqc8COGB4GYUM9YzSgLO_jIUli4RTQEQo,16655
|
3
3
|
py_near/constants.py,sha256=inaWIuwmF1EB5JSB0ynnZY5rKY_QsxhF9KuCOhPsM6k,164
|
4
4
|
py_near/dapps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
py_near/dapps/core.py,sha256=LtN9aW2gw2mvEdhzQcQJIidtjv-XL1xjb0LK8DzqtqE,231
|
@@ -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=a6u-JMmHnYAYKzHd1kde2DFG5afHRj6CUeo6x25isYk,12549
|
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.26.dist-info/LICENSE,sha256=I_GOA9xJ35FiL-KnYXZJdATkbO2KcV2dK2enRGVxzKM,1023
|
27
|
+
py_near-1.1.26.dist-info/METADATA,sha256=hv6OV_6SGxW8SV2njEBWEmmWFB7HV2oDDG6wmhgKawo,4713
|
28
|
+
py_near-1.1.26.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
29
|
+
py_near-1.1.26.dist-info/RECORD,,
|
File without changes
|
File without changes
|