Skip to content

Commit f6ba583

Browse files
authored
[EASY] Use unbuffered alloy provider (#3843)
# Description The following function uses unbuffered legacy web3 transport, while for Alloy it uses a regular provider. This PR fixes that. https://github.com/cowprotocol/services/blob/7fbb222595631f4d6b8099840e94bbe73870a845/crates/autopilot/src/run.rs#L106-L117 ## How to test N/A
1 parent 5bbffc5 commit f6ba583

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

crates/ethrpc/src/lib.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,21 @@ pub fn web3(
115115
) -> Web3 {
116116
let http = http_factory.cookie_store(true).build().unwrap();
117117
let http = HttpTransport::new(http, url.clone(), name.to_string());
118-
let transport = match args.into_buffered_configuration() {
119-
Some(config) => Web3Transport::new(BufferedTransport::with_config(http, config)),
120-
None => Web3Transport::new(http),
118+
let buffered_config = args.into_buffered_configuration();
119+
let (legacy, alloy, wallet) = match buffered_config {
120+
Some(config) => {
121+
let legacy = Web3Transport::new(BufferedTransport::with_config(http, config));
122+
let (alloy, wallet) = alloy::provider(url.as_str());
123+
(legacy, alloy, wallet)
124+
}
125+
None => {
126+
let legacy = Web3Transport::new(http);
127+
let (alloy, wallet) = alloy::unbuffered_provider(url.as_str());
128+
(legacy, alloy, wallet)
129+
}
121130
};
122-
let instrumented = instrumented::InstrumentedTransport::new(name.to_string(), transport);
123-
let (alloy, wallet) = alloy::provider(url.as_str());
131+
let instrumented = instrumented::InstrumentedTransport::new(name.to_string(), legacy);
132+
124133
Web3 {
125134
legacy: web3::Web3::new(Web3Transport::new(instrumented)),
126135
alloy,

0 commit comments

Comments
 (0)