Skip to content

Commit

Permalink
fix: Bump all exchanges to default max response bytes to 3KiB (#251)
Browse files Browse the repository at this point in the history
The exchange Mexc is failing on mainnet due to an increase in HTTP
header size. To solve this, this PR bumps the default max response bytes
to 3KiB. This will bump *every* exchange in order to be provide buffer
for every exchange source.
  • Loading branch information
dfinity-ryancroote authored Jan 30, 2024
1 parent 77cdb2c commit 0639555
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/xrc/src/exchanges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ trait IsExchange {
}

fn max_response_bytes(&self) -> u64 {
ONE_KIB
3 * ONE_KIB
}
}

Expand Down Expand Up @@ -248,10 +248,6 @@ impl IsExchange for Coinbase {
fn supported_stablecoin_pairs(&self) -> &[(&str, &str)] {
&[(USDT, USDC)]
}

fn max_response_bytes(&self) -> u64 {
2 * ONE_KIB
}
}

/// KuCoin
Expand Down Expand Up @@ -286,10 +282,6 @@ impl IsExchange for KuCoin {
fn supported_stablecoin_pairs(&self) -> &[(&str, &str)] {
&[(USDC, USDT), (USDT, DAI)]
}

fn max_response_bytes(&self) -> u64 {
2 * ONE_KIB
}
}

/// OKX
Expand Down Expand Up @@ -346,10 +338,6 @@ impl IsExchange for Okx {
fn supports_ipv6(&self) -> bool {
true
}

fn max_response_bytes(&self) -> u64 {
2 * ONE_KIB
}
}

/// Gate.io
Expand Down Expand Up @@ -736,19 +724,19 @@ mod test {
#[test]
fn max_response_bytes() {
let exchange = Exchange::Coinbase(Coinbase);
assert_eq!(exchange.max_response_bytes(), 2 * ONE_KIB);
assert_eq!(exchange.max_response_bytes(), 3 * ONE_KIB);
let exchange = Exchange::KuCoin(KuCoin);
assert_eq!(exchange.max_response_bytes(), 2 * ONE_KIB);
assert_eq!(exchange.max_response_bytes(), 3 * ONE_KIB);
let exchange = Exchange::Okx(Okx);
assert_eq!(exchange.max_response_bytes(), 2 * ONE_KIB);
assert_eq!(exchange.max_response_bytes(), 3 * ONE_KIB);
let exchange = Exchange::GateIo(GateIo);
assert_eq!(exchange.max_response_bytes(), ONE_KIB);
assert_eq!(exchange.max_response_bytes(), 3 * ONE_KIB);
let exchange = Exchange::Mexc(Mexc);
assert_eq!(exchange.max_response_bytes(), ONE_KIB);
assert_eq!(exchange.max_response_bytes(), 3 * ONE_KIB);
let exchange = Exchange::Poloniex(Poloniex);
assert_eq!(exchange.max_response_bytes(), ONE_KIB);
assert_eq!(exchange.max_response_bytes(), 3 * ONE_KIB);
let exchange = Exchange::CryptoCom(CryptoCom);
assert_eq!(exchange.max_response_bytes(), ONE_KIB);
assert_eq!(exchange.max_response_bytes(), 3 * ONE_KIB);
}

#[test]
Expand Down

0 comments on commit 0639555

Please sign in to comment.