@@ -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 :
0 commit comments