From 519c312e8d121f3a8b4d7ee84d1eeb86d89e3d5d Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 12 Sep 2022 23:00:10 +0000 Subject: [PATCH] reconnect needs to clear more state --- web3_proxy/src/rpcs/connection.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/web3_proxy/src/rpcs/connection.rs b/web3_proxy/src/rpcs/connection.rs index 2e7f224c..25adc5ac 100644 --- a/web3_proxy/src/rpcs/connection.rs +++ b/web3_proxy/src/rpcs/connection.rs @@ -259,9 +259,24 @@ impl Web3Connection { { let mut provider = self.provider.write().await; + // our provider doesn't work anymore *provider = None; - // TODO: if this fails, keep retrying + // reset sync status + { + let mut head_block_id = self.head_block_id.write(); + *head_block_id = None; + } + + // tell the block subscriber that we don't have any blocks + if let Some(block_sender) = &block_sender { + block_sender + .send_async((None, self.clone())) + .await + .context("block_sender during reconnect clear")?; + } + + // TODO: if this fails, keep retrying! otherwise it crashes and doesn't try again! let new_provider = Web3Provider::from_str(&self.url, http_client) .await .unwrap(); @@ -299,6 +314,7 @@ impl Web3Connection { ) -> anyhow::Result<()> { match new_head_block { Ok(None) => { + // TODO: i think this should clear the local block and then update over the block sender todo!("handle no block") } Ok(Some(mut new_head_block)) => {