Open 0xKitsune opened 1 week ago
Hi @0xKitsune thanks for your suggestion
I think this could be useful addition, would be added to https://github.com/alloy-rs/alloy/tree/main/crates/transport/src/layers
cc @yash-atreya / @mattsse
Would be great if https://github.com/alloy-rs/alloy/issues/1147 is also considered as part of this scope / tested with wasm32-unknown-none
Component
rpc, transports
Describe the feature you would like
In some instances, it would be useful to have a
ThrottleLayer
to not flood the node with requests all at once. While theRetryLayer
works perfectly for retrying requests that exceed RPC provider limits, theThrottleLayer
could throttle outbound requests before they are sent.The following snippet shows an example that fetches 100k blocks concurrently. In this example a
ThrottleLayer
would be helpful to limitn
requests per second.We currently have a working version of a ThrottleLayer built and I would be happy to open a draft PR with this if you think it would be useful to add to
alloy
.Additional context
No response