tomusdrw / rust-web3

Ethereum JSON-RPC multi-transport client. Rust implementation of web3 library. ENS address: rust-web3.eth
MIT License
1.45k stars 465 forks source link

feat: webSockets reconnecting #675

Closed litcc closed 1 year ago

litcc commented 1 year ago

I have added websocket disconnect reconnection and related close hook functions without changing the original architecture as much as possible; however, I have not tested it extensively and only tested it locally, and no problems have been found in the local tests for the time being.

when I subscribe to a new block, if the connection is disconnected, the new block header event may be lost before reconnecting and before re-initiating the subscription; I don't know if the subscription should be further processed to prevent data loss during reconnection.

I would like to understand if the idea of my code implementation makes sense.

https://github.com/litcc/rust-web3/commit/72f1aa19b9c7e81176437faa055149b42a2c5e87