Skip to content

Commit 1d1b8e0

Browse files
committed
Update online_nodes query
1 parent b858b0a commit 1d1b8e0

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

meile_online_nodes.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import grpc
77
from grpc import StatusCode
88
from sentinel_sdk.sdk import SDKInstance
9-
from sentinel_sdk.types import PageRequest, Status
9+
from sentinel_sdk.types import PageRequest, Status, NodeType
1010
from sentinel_sdk.modules.node import NodeModule
1111

1212
GRPCs = [
@@ -80,6 +80,7 @@ def QueryAndRepopulateDB(self, db):
8080
grpc_status_code = StatusCode.UNAVAILABLE
8181

8282
nodesStatus = sdk.nodes.QueryNodesStatus(nodes)
83+
#print(nodeStatus)
8384
self.DropTableAndCreateNew(db)
8485
'''value of nodesStatus
8586
('sentnode16gswagztkv4q8h4hc89stk2ndc2avgthc45lpx', '{"success":true,"result":{"address":"sentnode16gswagztkv4q8h4hc89stk2ndc2avgthc45lpx","bandwidth":{"download":166750000,"upload":321125000},"handshake":{"enable":false,"peers":8},"interval_set_sessions":1
@@ -93,24 +94,33 @@ def QueryAndRepopulateDB(self, db):
9394
'''
9495
for a,d in nodesStatus.items():
9596
try:
96-
if json.loads(d)['success']:
97+
data = json.loads(d)
98+
if data['success']:
9799
result = json.loads(d)['result']
98-
address = result['address'] # VARCHAR(100)
99-
bandwidth_down = int(result['bandwidth']['download']) # BIGINT
100-
bandwidth_up = int(result['bandwidth']['upload']) # BIGINT
101-
handshake = result['handshake']['enable'] # Boolean
100+
address = result['addr'] # VARCHAR(100)
101+
bandwidth_down = int(result['downlink']) # BIGINT
102+
bandwidth_up = int(result['uplink']) # BIGINT
103+
handshake = result['handshake_dns'] # Boolean
102104
city = result['location']['city'] # VARCHAR(100)
103105
country = result['location']['country'] #VARCHAR(100)
104106
latitude = float(result['location']['latitude']) #DECIMAL(7,4)
105107
longitude = float(result['location']['longitude']) #DECIMAL(7,4)
106108
moniker = result['moniker'] # VARCHAR(200)
107-
wallet = result['operator'] #VARCHAR(100)
109+
#wallet = result['operator'] #VARCHAR(100)
110+
wallet = " " #VARCHAR(100)
108111
peers = int(result['peers']) #SMALLINT
109-
gb_prices = result['gigabyte_prices'] #VARCHAR(2000)
110-
hr_prices = result['hourly_prices'] #VARCHAR(2000)
111-
max_peers = int(result['qos']['max_peers']) #SMALLINT
112-
node_type = int(result['type']) #SMALLINT
113-
node_version = result['version'] #VARCHAR(20)
112+
gb_prices = data['gigabyte_prices'] #VARCHAR(2000)
113+
hr_prices = data['hourly_prices'] #VARCHAR(2000)
114+
#max_peers = int(result['qos']['max_peers']) #SMALLINT
115+
max_peers = 250 #SMALLINT
116+
# node_type = result['service_type'] #SMALLINT
117+
if result['service_type'] == "wireguard":
118+
node_type = 1
119+
elif result['service_type'] == "v2ray":
120+
node_type = 2
121+
else:
122+
node_type = 3
123+
node_version = result['version']['tag'] #VARCHAR(20)
114124

115125
if "ncosmic" in gb_prices or "ncosmic" in hr_prices:
116126
continue

0 commit comments

Comments
 (0)