Skip to content

Conversation

@dipanshuhappy
Copy link
Contributor

Motivation

Resolves #3150

Solution

This is how I imagine the flow to be

    Poller starts with params: (filter_id_123,)
    Makes RPC calls: eth_getFilterChanges(filter_id_123)
    Server responds: "filter not found"
    Poller says: "Let me get new params"
    Poller calls reconnection logic: (old_filter_id) → (new_filter_id)
    Poller continues with new params: (filter_id_456,)

In terms of code, I imagine it to look like this

let poller = PollerBuilder::new(client, "eth_getFilterChanges", (filter_id,))
     .with_reconnect(|weak_client| async move {
        let client = weak_client.upgrade().ok_or("client dropped")?;
        let new_filter = client.request_noparams("eth_newBlockFilter").await?;
        serde_json::value::to_raw_value(&(new_filter,))
         .map_err(TransportError::ser_err)
 });

PS: I kinda tested this, I wasn't able to recreate the filter dropping, couldn't get the right amount of time to wait such that it drops but I did try if it does enter the error if it updates the params with the with_reconnect function. And it does.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Feature] Make PollerStream reconnectable

2 participants