@@ -19,9 +19,12 @@ use linera_base::{
1919 command:: { resolve_binary, CommandExt } ,
2020 data_types:: Amount ,
2121} ;
22- use linera_client:: client_options:: ResourceControlPolicyConfig ;
22+ use linera_client:: {
23+ client_options:: ResourceControlPolicyConfig ,
24+ config:: { BlockExporterConfig , DestinationKind } ,
25+ } ;
2326use linera_core:: node:: ValidatorNodeProvider ;
24- use linera_rpc:: config:: CrossChainConfig ;
27+ use linera_rpc:: config:: { CrossChainConfig , TlsConfig } ;
2528#[ cfg( all( feature = "storage-service" , with_testing) ) ]
2629use linera_storage_service:: common:: storage_service_test_endpoint;
2730#[ cfg( all( feature = "rocksdb" , feature = "scylladb" , with_testing) ) ]
@@ -184,7 +187,7 @@ pub struct LocalNetConfig {
184187 pub cross_chain_config : CrossChainConfig ,
185188 pub storage_config_builder : InnerStorageConfigBuilder ,
186189 pub path_provider : PathProvider ,
187- pub num_block_exporters : u32 ,
190+ pub block_exporters : Vec < BlockExporterConfig > ,
188191}
189192
190193/// A set of Linera validators running locally as native processes.
@@ -202,7 +205,7 @@ pub struct LocalNet {
202205 common_storage_config : InnerStorageConfig ,
203206 cross_chain_config : CrossChainConfig ,
204207 path_provider : PathProvider ,
205- num_block_exporters : u32 ,
208+ block_exporters : Vec < BlockExporterConfig > ,
206209}
207210
208211/// The name of the environment variable that allows specifying additional arguments to be passed
@@ -305,7 +308,7 @@ impl LocalNetConfig {
305308 num_proxies,
306309 storage_config_builder,
307310 path_provider,
308- num_block_exporters : 0 ,
311+ block_exporters : vec ! [ ] ,
309312 }
310313 }
311314}
@@ -326,7 +329,7 @@ impl LineraNetConfig for LocalNetConfig {
326329 storage_config,
327330 self . cross_chain_config ,
328331 self . path_provider ,
329- self . num_block_exporters ,
332+ self . block_exporters ,
330333 ) ?;
331334 let client = net. make_client ( ) . await ;
332335 ensure ! (
@@ -391,7 +394,7 @@ impl LocalNet {
391394 common_storage_config : InnerStorageConfig ,
392395 cross_chain_config : CrossChainConfig ,
393396 path_provider : PathProvider ,
394- num_block_exporters : u32 ,
397+ block_exporters : Vec < BlockExporterConfig > ,
395398 ) -> Result < Self > {
396399 Ok ( Self {
397400 network,
@@ -407,7 +410,7 @@ impl LocalNet {
407410 common_storage_config,
408411 cross_chain_config,
409412 path_provider,
410- num_block_exporters ,
413+ block_exporters ,
411414 } )
412415 }
413416
@@ -501,9 +504,9 @@ impl LocalNet {
501504 ) ) ;
502505 }
503506
504- for j in 0 ..self . num_block_exporters {
507+ for j in 0 ..self . block_exporters . len ( ) {
505508 let host = Network :: Grpc . localhost ( ) ;
506- let port = Self :: block_exporter_port ( n, j as usize ) ;
509+ let port = Self :: block_exporter_port ( n, j) ;
507510 let config_content = format ! (
508511 r#"
509512
@@ -514,7 +517,7 @@ impl LocalNet {
514517 ) ;
515518
516519 content. push_str ( & config_content) ;
517- let exporter_config = self . generate_block_exporter_config ( n, j) ;
520+ let exporter_config = self . generate_block_exporter_config ( n, j as u32 ) ;
518521 let config_path = self
519522 . path_provider
520523 . path ( )
@@ -536,7 +539,7 @@ impl LocalNet {
536539 let n = validator;
537540 let host = Network :: Grpc . localhost ( ) ;
538541 let port = Self :: block_exporter_port ( n, exporter_id as usize ) ;
539- let config = format ! (
542+ let mut config = format ! (
540543 r#"
541544 id = {exporter_id}
542545
@@ -546,6 +549,36 @@ impl LocalNet {
546549 "#
547550 ) ;
548551
552+ for destination in & self . block_exporters [ exporter_id as usize ]
553+ . destination_config
554+ . destinations
555+ {
556+ let tls = match destination. tls {
557+ TlsConfig :: ClearText => "ClearText" ,
558+ TlsConfig :: Tls => "Tls" ,
559+ } ;
560+
561+ let endpoint = & destination. endpoint ;
562+ let port = destination. port ;
563+ let kind = match destination. kind {
564+ DestinationKind :: Indexer => "Indexer" ,
565+ DestinationKind :: Validator => "Validator" ,
566+ } ;
567+
568+ let destination_string_to_push = format ! (
569+ r#"
570+
571+ [[destination_config.destinations]]
572+ tls = "{tls}"
573+ endpoint = "{endpoint}"
574+ port = {port}
575+ kind = "{kind}"
576+ "#
577+ ) ;
578+
579+ config. push_str ( & destination_string_to_push) ;
580+ }
581+
549582 config
550583 }
551584
@@ -799,8 +832,8 @@ impl LocalNet {
799832 let server = self . run_server ( index, shard) . await ?;
800833 validator. add_server ( server) ;
801834 }
802- for block_exporter in 0 ..self . num_block_exporters {
803- let exporter = self . run_exporter ( index, block_exporter) . await ?;
835+ for block_exporter in 0 ..self . block_exporters . len ( ) {
836+ let exporter = self . run_exporter ( index, block_exporter as u32 ) . await ?;
804837 validator. add_block_exporter ( exporter) ;
805838 }
806839 self . running_validators . insert ( index, validator) ;
0 commit comments