AlexNijjar commited on
Commit
84168a6
·
1 Parent(s): c74ed7f

Catch subtensor issues

Browse files
Files changed (2) hide show
  1. .DS_Store +0 -0
  2. src/chain_data.py +25 -20
.DS_Store ADDED
Binary file (6.15 kB). View file
 
src/chain_data.py CHANGED
@@ -42,11 +42,13 @@ def fetch_incentives():
42
  for i in range(len(metagraph.incentive)):
43
  INCENTIVES[i] = metagraph.incentive[i]
44
 
 
45
  def fetch_vtrust():
46
  VTRUST.clear()
47
  for i in range(len(metagraph.validator_trust)):
48
  VTRUST[i] = metagraph.validator_trust[i]
49
 
 
50
  def fetch_updated():
51
  UPDATED.clear()
52
  block = subtensor.get_current_block()
@@ -69,23 +71,26 @@ last_identity_sync: datetime = datetime.fromtimestamp(0, TIMEZONE)
69
 
70
 
71
  def sync_metagraph():
72
- global last_sync
73
- now = datetime.now(TIMEZONE)
74
- if now - last_sync < timedelta(minutes=5):
75
- return
76
-
77
- print("Syncing metagraph...")
78
- last_sync = now
79
- metagraph.sync(subtensor=subtensor)
80
-
81
- fetch_weights()
82
- fetch_incentives()
83
- fetch_vtrust()
84
- fetch_updated()
85
-
86
- global last_identity_sync
87
- if now - last_identity_sync < timedelta(hours=12):
88
- return
89
-
90
- last_identity_sync = now
91
- fetch_identities()
 
 
 
 
42
  for i in range(len(metagraph.incentive)):
43
  INCENTIVES[i] = metagraph.incentive[i]
44
 
45
+
46
  def fetch_vtrust():
47
  VTRUST.clear()
48
  for i in range(len(metagraph.validator_trust)):
49
  VTRUST[i] = metagraph.validator_trust[i]
50
 
51
+
52
  def fetch_updated():
53
  UPDATED.clear()
54
  block = subtensor.get_current_block()
 
71
 
72
 
73
  def sync_metagraph():
74
+ try:
75
+ global last_sync
76
+ now = datetime.now(TIMEZONE)
77
+ if now - last_sync < timedelta(minutes=5):
78
+ return
79
+
80
+ print("Syncing metagraph...")
81
+ last_sync = now
82
+ metagraph.sync(subtensor=subtensor)
83
+
84
+ fetch_weights()
85
+ fetch_incentives()
86
+ fetch_vtrust()
87
+ fetch_updated()
88
+
89
+ global last_identity_sync
90
+ if now - last_identity_sync < timedelta(hours=12):
91
+ return
92
+
93
+ last_identity_sync = now
94
+ fetch_identities()
95
+ except:
96
+ ...