-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configure polling interval #437
Conversation
This wouldn't work. Making changes |
crates/rpc-client/src/client.rs
Outdated
inner.set_poll_interval(poll_interval); | ||
self | ||
} else { | ||
todo!("TBD: Value is already shared. Cannot be mutated"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could have the poll interval be an atomic number of seconds instead of a duration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we have it as an atomic number, we would still need to use Arc::get_mut
since RpcClientInner
is wrapped in Arc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
atomics don't require a &mut
reference to modify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good. only nit
/// Note: Sets the poll interval to 250ms for local transports and 7s for remote transports by | ||
/// default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could tweak this based in the chain, because 7s exceeds avg blocktime of a lot of chains.
the alloy_chains::Chain has a function for this.
so we could integrate this in eth_chainId call for example and track whether we've already set the poll_interval based on chain_id
transport: t, | ||
is_local, | ||
id: AtomicU64::new(0), | ||
poll_interval: if is_local { AtomicU64::new(250) } else { AtomicU64::new(7000) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd make this 2s given the rise of L2s with faster blocktimes
* feat(rpc-client): add set_poll_interval method * fix: using with_poll_interval in RpcClient * use AtomicU64 for poll interval * PollerBuilder nits * fix test * store Ordering::Relaxed
Motivation
#290
Solution
Add methods to
RpcClient
andRootProvider
to configure the polling interval.PR Checklist