77logger = logging .getLogger ('exporter' )
88LOGLEVEL = os .environ .get ('LOGLEVEL' , 'INFO' ).upper ()
99
10- logging .basicConfig (level = LOGLEVEL ,
11- format = "{'thread': '%(threadName)s', 'level': '%(levelname)s', 'message': '%(message)s'}" )
10+ logging .basicConfig (
11+ level = LOGLEVEL ,
12+ format =
13+ "{'thread': '%(threadName)s', 'level': '%(levelname)s', 'message': '%(message)s'}"
14+ )
1215
1316
1417class configuration ():
1518
1619 def __init__ (self , config_file_path : str , validation_file_path : str ):
17- self .allowed_providers = self ._load_validation_file (validation_file_path )
20+ self .allowed_providers = self ._load_validation_file (
21+ validation_file_path )
1822 self .configuration = self ._load_configuration_file (config_file_path )
1923 self .blockchain = self .configuration ['blockchain' ]
2024 # Load chain_id only if evm compatible collector
21- if self .configuration ['collector' ] not in ['cardano' , 'solana' , 'bitcoin' , 'doge' , 'filecoin' ]:
25+ if self .configuration ['collector' ] not in [
26+ 'cardano' , 'solana' , 'bitcoin' , 'doge' , 'filecoin' , 'starkware'
27+ ]:
2228 try :
2329 self .chain_id = self .configuration ['chain_id' ]
2430 except KeyError :
25- logger .error ("This chain requires chain_id configuration, but it is not provided." )
31+ logger .error (
32+ "This chain requires chain_id configuration, but it is not provided."
33+ )
2634 self .network_type = self .configuration ['network_type' ]
2735 self .network_name = self .configuration ['network_name' ]
2836 self .endpoints = self .configuration ['endpoints' ]
2937 try :
30- self .open_timeout = self .configuration ['connection_parameters' ]['open_timeout' ]
38+ self .open_timeout = self .configuration ['connection_parameters' ][
39+ 'open_timeout' ]
3140 except KeyError :
3241 self .open_timeout = 3
3342 try :
34- self .close_timeout = self .configuration ['connection_parameters' ]['close_timeout' ]
43+ self .close_timeout = self .configuration ['connection_parameters' ][
44+ 'close_timeout' ]
3545 except KeyError :
3646 self .close_timeout = 1
3747 try :
38- self .response_timeout = self .configuration ['connection_parameters' ]['response_timeout' ]
48+ self .response_timeout = self .configuration [
49+ 'connection_parameters' ]['response_timeout' ]
3950 except KeyError :
4051 self .response_timeout = 3
4152 try :
42- self .ping_interval = self .configuration ['connection_parameters' ]['ping_interval' ]
53+ self .ping_interval = self .configuration ['connection_parameters' ][
54+ 'ping_interval' ]
4355 except KeyError :
4456 self .ping_interval = 6
4557 try :
46- self .ping_timeout = self .configuration ['connection_parameters' ]['ping_timeout' ]
58+ self .ping_timeout = self .configuration ['connection_parameters' ][
59+ 'ping_timeout' ]
4760 except KeyError :
4861 self .ping_timeout = 2
4962
@@ -85,6 +98,9 @@ def isDoge(self) -> bool:
8598 def isFilecoin (self ) -> bool :
8699 return self .configuration ['collector' ] == "filecoin"
87100
101+ def isStarkware (self ) -> bool :
102+ return self .configuration ['collector' ] == "starkware"
103+
88104 def _load_configuration_file (self , path ):
89105 logger .info ('Loading {}' .format (path ))
90106 configuration_file_schema = Schema ({
@@ -97,7 +113,10 @@ def _load_configuration_file(self, path):
97113 'network_type' :
98114 And (str , lambda s : s in ('Testnet' , 'Mainnet' )),
99115 'collector' :
100- And (str , lambda s : s in ('evm' , 'cardano' , 'conflux' , 'solana' , 'bitcoin' , 'doge' , 'filecoin' )),
116+ And (
117+ str , lambda s : s in
118+ ('evm' , 'cardano' , 'conflux' , 'solana' , 'bitcoin' , 'doge' ,
119+ 'filecoin' , 'starkware' )),
101120 Optional ('connection_parameters' ): {
102121 Optional ('open_timeout' ): And (int ),
103122 Optional ('close_timeout' ): And (int ),
@@ -106,9 +125,12 @@ def _load_configuration_file(self, path):
106125 Optional ('ping_timeout' ): And (int ),
107126 },
108127 'endpoints' : [{
109- Optional ('ws_url' ): And (str ),
110- Optional ('https_url' ): And (str ),
111- 'provider' : And (str , lambda s : s in self .allowed_providers )
128+ Optional ('ws_url' ):
129+ And (str ),
130+ Optional ('https_url' ):
131+ And (str ),
132+ 'provider' :
133+ And (str , lambda s : s in self .allowed_providers )
112134 }]
113135 })
114136 try :
@@ -129,11 +151,13 @@ def _load_file(self, path):
129151 logger .info ('Validating {}' .format (path ))
130152 return file
131153 except IOError as e :
132- logger .error ('Problem with configuration file detected: {}' .format (e ))
154+ logger .error (
155+ 'Problem with configuration file detected: {}' .format (e ))
133156 exit (1 )
134157
135158
136159cfg_file_path = os .getenv ('CONFIG_FILE_PATH' , default = '/config/config.yml' )
137- valid_file_path = os .getenv ('VALIDATION_FILE_PATH' , default = '/config/validation.yml' )
160+ valid_file_path = os .getenv ('VALIDATION_FILE_PATH' ,
161+ default = '/config/validation.yml' )
138162
139163cfg = configuration (cfg_file_path , valid_file_path )
0 commit comments