@@ -68,6 +68,7 @@ pub struct Config {
68
68
pub history_url : Url ,
69
69
pub relayer_urls : Vec < Url > ,
70
70
pub publish_keypair_path : PathBuf ,
71
+ pub authorization_token : Option < String > ,
71
72
#[ serde( with = "humantime_serde" , default = "default_publish_interval" ) ]
72
73
pub publish_interval_duration : Duration ,
73
74
#[ serde( with = "humantime_serde" , default = "default_symbol_fetch_interval" ) ]
@@ -292,13 +293,22 @@ pub fn lazer_exporter(config: Config, state: Arc<state::State>) -> Vec<JoinHandl
292
293
let pubkey_base64 = BASE64_STANDARD . encode ( signing_key. verifying_key ( ) . to_bytes ( ) ) ;
293
294
tracing:: info!( "Loaded Lazer signing key; pubkey in base64: {pubkey_base64}" ) ;
294
295
296
+ let authorization_token = if let Some ( authorization_token) = config. authorization_token . clone ( )
297
+ {
298
+ // If authorization_token is configured, use it.
299
+ authorization_token
300
+ } else {
301
+ // Otherwise, use the base64 pubkey.
302
+ pubkey_base64
303
+ } ;
304
+
295
305
// can safely drop first receiver for ease of iteration
296
306
let ( relayer_sender, _) = broadcast:: channel ( RELAYER_CHANNEL_CAPACITY ) ;
297
307
298
308
for url in config. relayer_urls . iter ( ) {
299
309
let mut task = RelayerSessionTask {
300
310
url : url. clone ( ) ,
301
- token : pubkey_base64 . clone ( ) ,
311
+ token : authorization_token . clone ( ) ,
302
312
receiver : relayer_sender. subscribe ( ) ,
303
313
} ;
304
314
handles. push ( tokio:: spawn ( async move { task. run ( ) . await } ) ) ;
@@ -725,6 +735,7 @@ mod tests {
725
735
history_url : Url :: parse ( "http://127.0.0.1:12345" ) . unwrap ( ) ,
726
736
relayer_urls : vec ! [ Url :: parse( "http://127.0.0.1:12346" ) . unwrap( ) ] ,
727
737
publish_keypair_path : PathBuf :: from ( private_key_file. path ( ) ) ,
738
+ authorization_token : None ,
728
739
publish_interval_duration : Duration :: from_secs ( 1 ) ,
729
740
symbol_fetch_interval_duration : Duration :: from_secs ( 60 * 60 ) ,
730
741
} ;
0 commit comments