diff --git a/config/importer-online.env.local b/config/importer-online.env.local index c1ae1c119..28bc12f99 100644 --- a/config/importer-online.env.local +++ b/config/importer-online.env.local @@ -1,3 +1,5 @@ +RUST_LOG=importer_online=info,stratus=info + CHAIN_ID=2008 EVMS=1 diff --git a/src/infra/blockchain_client/blockchain_client.rs b/src/infra/blockchain_client/blockchain_client.rs index 69c848962..5bae03895 100644 --- a/src/infra/blockchain_client/blockchain_client.rs +++ b/src/infra/blockchain_client/blockchain_client.rs @@ -249,11 +249,11 @@ impl BlockchainClient { pub async fn subscribe_new_heads(&self) -> anyhow::Result> { tracing::debug!("subscribing to newHeads event"); - let ws = self.require_ws().await?; let mut first_attempt = true; loop { - let result = ws + let ws_read = self.require_ws().await?; + let result = ws_read .subscribe::>("eth_subscribe", vec![JsonValue::String("newHeads".to_owned())], "eth_unsubscribe") .await; @@ -274,8 +274,9 @@ impl BlockchainClient { // reconnect websocket client let new_ws_client = Self::build_ws_client(self.ws_url.as_ref().unwrap(), self.timeout).await?; - let mut current_ws_client = self.ws.as_ref().unwrap().write().await; - let _ = std::mem::replace(&mut *current_ws_client, new_ws_client); + drop(ws_read); + let mut ws_write = self.ws.as_ref().unwrap().write().await; + let _ = std::mem::replace(&mut *ws_write, new_ws_client); } // failed and cannot do anything