@@ -15,7 +15,7 @@ use electrs::{
1515 electrum:: RPC as ElectrumRPC ,
1616 errors:: * ,
1717 metrics:: Metrics ,
18- new_index:: { precache, ChainQuery , FetchFrom , Indexer , Mempool , Query , Store } ,
18+ new_index:: { precache, zmq , ChainQuery , FetchFrom , Indexer , Mempool , Query , Store } ,
1919 rest,
2020 signal:: Waiter ,
2121} ;
@@ -45,6 +45,10 @@ fn run_server(config: Arc<Config>) -> Result<()> {
4545 let metrics = Metrics :: new ( config. monitoring_addr ) ;
4646 metrics. start ( ) ;
4747
48+ if let Some ( zmq_addr) = config. zmq_addr . as_ref ( ) {
49+ zmq:: start ( & format ! ( "tcp://{zmq_addr}" ) , None ) ;
50+ }
51+
4852 let daemon = Arc :: new ( Daemon :: new (
4953 & config. daemon_dir ,
5054 & config. blocks_dir ,
@@ -85,9 +89,12 @@ fn run_server(config: Arc<Config>) -> Result<()> {
8589 match Mempool :: update ( & mempool, & daemon) {
8690 Ok ( _) => break ,
8791 Err ( e) => {
88- warn ! ( "Error performing initial mempool update, trying again in 5 seconds: {}" , e. display_chain( ) ) ;
92+ warn ! (
93+ "Error performing initial mempool update, trying again in 5 seconds: {}" ,
94+ e. display_chain( )
95+ ) ;
8996 signal. wait ( Duration :: from_secs ( 5 ) , false ) ?;
90- } ,
97+ }
9198 }
9299 }
93100
@@ -117,7 +124,6 @@ fn run_server(config: Arc<Config>) -> Result<()> {
117124 ) ) ;
118125
119126 loop {
120-
121127 main_loop_count. inc ( ) ;
122128
123129 if let Err ( err) = signal. wait ( Duration :: from_secs ( 5 ) , true ) {
@@ -137,7 +143,10 @@ fn run_server(config: Arc<Config>) -> Result<()> {
137143 // Update mempool
138144 if let Err ( e) = Mempool :: update ( & mempool, & daemon) {
139145 // Log the error if the result is an Err
140- warn ! ( "Error updating mempool, skipping mempool update: {}" , e. display_chain( ) ) ;
146+ warn ! (
147+ "Error updating mempool, skipping mempool update: {}" ,
148+ e. display_chain( )
149+ ) ;
141150 }
142151
143152 // Update subscribed clients
0 commit comments