Skip to content

Commit 0b250c4

Browse files
committed
better to start with small batch requests and count up rather than down to avoid long rate limit blocks from figuring our batch limit
1 parent 6cc14da commit 0b250c4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

IceCreamSwapWeb3/Web3Advanced.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,19 @@ def _find_max_filter_range(self) -> int:
112112
return 0
113113

114114
def _find_max_batch_size(self) -> int:
115-
for batch_size in self.BATCH_SIZES_TO_TRY:
116-
try:
115+
working_size = 0
116+
try:
117+
for batch_size in reversed(self.BATCH_SIZES_TO_TRY):
117118
with self.batch_requests() as batch:
118119
for _ in range(batch_size):
119120
batch.add(self.eth._gas_price())
120121
result = batch.execute()
121122
assert len(result) == batch_size
122-
return batch_size
123-
except Exception:
123+
working_size = batch_size
124124
sleep(0.1)
125-
print(f"Can not use batch requests with RPC {self.node_url}")
126-
return 0
125+
except Exception:
126+
pass
127+
return working_size
127128

128129
def _check_revert_reason_available(self):
129130
with files("IceCreamSwapWeb3").joinpath("./abi/RevertTester.abi").open('r') as f:

0 commit comments

Comments
 (0)