Skip to content

Commit 084c906

Browse files
committed
Update node modules - QueryNodeStatus() to include prices. Update types. Update subscription module
1 parent 58d8379 commit 084c906

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "sentinel_sdk"
7-
version = "0.0.5"
7+
version = "0.1.0"
88
description = "A Sentinel SDK Written in Python"
99
authors = [
1010
{ name = "NAST0R" },
@@ -13,7 +13,7 @@ authors = [
1313
]
1414
readme = "README.md"
1515
requires-python = ">=3.10"
16-
keywords = ["sentinel_sdk", "mospy", "sentinel", "cosmos", "protobuf", "sentinel_protobuf"]
16+
keywords = ["sentinel_sdk", "mospy", "sentinel", "dvpn", "cosmos", "protobuf", "sentinel_protobuf"]
1717
license = {text = "GPL-3.0 license"}
1818
classifiers = [
1919
"Development Status :: 3 - Alpha",
@@ -22,7 +22,7 @@ classifiers = [
2222
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
2323
]
2424
dependencies = [
25-
"sentinel-protobuf==0.3.3",
25+
"sentinel-protobuf==0.4.3",
2626
"grpcio>=1.51.1",
2727
"bip-utils==2.9.0",
2828
"mospy-wallet==0.6.0",

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sentinel-protobuf==0.3.3
1+
sentinel-protobuf==0.4.3
22
grpcio>=1.51.1
33
bip-utils==2.9.0
4-
mospy-wallet @ git+https://github.com/Tkd-Alex/mospy.git@development
4+
mospy-wallet==0.6.0

src/sentinel_sdk/modules/node.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def __init__(self, channel: grpc.Channel, node_timeout: int, account, client):
3737
self._client = client
3838

3939
self.__nodes_status_cache = {}
40-
40+
4141
def QueryParams(self) -> Any:
4242
return self.__stub.QueryParams(sentinel_node_v3_querier_pb2.QueryParamsRequest()).params
43-
43+
4444
def QueryNode(self, address: str) -> Any:
4545
r = self.__stub.QueryNode(
4646
sentinel_node_v3_querier_pb2.QueryNodeRequest(address=address)
@@ -63,22 +63,45 @@ def QueryNumOfNodesWithStatus(self, status: int) -> int:
6363
return r.pagination.total
6464

6565
def QueryNodeStatus(self, node: node_pb2.Node, is_in_thread: bool = False) -> str:
66-
node_endpoint = node.remote_url
66+
node_endpoint = "https://" + node.remote_addrs[0]
67+
gb_price = ""
68+
hr_price = ""
69+
if node.gigabyte_prices:
70+
for prices in node.gigabyte_prices:
71+
gb_price = gb_price + prices.quote_value + prices.denom + ','
72+
else:
73+
gb_price = "0.0udvpn"
74+
if node.hourly_prices:
75+
for prices in node.hourly_prices:
76+
hr_price = hr_price + prices.quote_value + prices.denom + ','
77+
else:
78+
hr_price = "0.0udvpn"
79+
80+
gb_price = gb_price.rstrip(',')
81+
hr_price = hr_price.rstrip(',')
82+
print(f"GB Prices: {gb_price}\n Hourly Prices: {hr_price}")
83+
print(f"Node Endpoint: {node_endpoint}")
6784
try:
6885
contents = urllib.request.urlopen(
69-
f"{node_endpoint}/status",
86+
f"{node_endpoint}",
7087
context=self.__ssl_ctx,
7188
timeout=self.node_timeout,
7289
).read()
7390
contents = contents.decode("utf-8")
74-
except urllib.error.URLError:
91+
except urllib.error.URLError as E:
92+
print(str(E))
7593
contents = '{"success":false,"urllib-error":"URLError encountered"}'
7694
except TimeoutError:
7795
contents = '{"success":false,"urllib-error":"Data reading timed out"}'
7896
except http.client.RemoteDisconnected:
7997
contents = '{"success":false,"http-error":"Remote endpoint closed connection"}'
8098
except:
8199
contents = '{"success":false,"error":"Unrecognizable error encountered"}'
100+
contents = json.loads(contents)
101+
contents['gigabyte_prices'] = gb_price
102+
contents['hourly_prices'] = hr_price
103+
contents = json.dumps(contents)
104+
82105
if is_in_thread:
83106
self.__nodes_status_cache[node.address] = contents
84107
else:

src/sentinel_sdk/querier/querier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def QueryAll(
1212
pagination: PageRequest = None,
1313
**kwargs,
1414
) -> list:
15+
1516
# ["status", "address", "id"] are the only valid kwargs
1617
request_arguments = {
1718
k: kwargs[k] for k in kwargs if k in ["status", "address", "id"]
@@ -34,5 +35,4 @@ def QueryAll(
3435
# Stop iteration if PageRequest contain a offset value
3536
if pagination.offset is not None:
3637
break
37-
3838
return items

src/sentinel_sdk/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __str__(self):
1818
class NodeType(Enum):
1919
WIREGUARD = 1
2020
V2RAY = 2
21+
OPENVPN = 3
2122

2223
class RenewalPricePolicy(Enum):
2324
RENEWAL_PRICE_POLICY_UNSPECIFIED = 0

0 commit comments

Comments
 (0)