Skip to content

Commit f9e9962

Browse files
committed
fixed progress bar when getting logs through Subsquid
1 parent 3044cc2 commit f9e9962

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

IceCreamSwapWeb3/EthAdvanced.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def get_logs(
188188
chain_id=self.chain_id,
189189
filter_params=filter_params,
190190
partial_allowed=True,
191+
p_bar=p_bar,
191192
)
192193
if till_block >= to_block:
193194
return results

IceCreamSwapWeb3/Subsquid.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import requests
22
from eth_utils import to_checksum_address
33
from hexbytes import HexBytes
4+
from tqdm import tqdm
45
from web3.types import FilterParams, LogReceipt
56

67
ENDPOINTS = {
@@ -113,7 +114,8 @@ def get_text(url: str) -> str:
113114
def get_filter(
114115
chain_id: int,
115116
filter_params: FilterParams,
116-
partial_allowed=False
117+
partial_allowed=False,
118+
p_bar: tqdm = None
117119
) -> tuple[int, list[LogReceipt]]:
118120
if chain_id not in ENDPOINTS:
119121
raise ValueError(f"Subsquid does not support Chain ID {chain_id}")
@@ -176,6 +178,8 @@ def get_filter(
176178
blocks = res.json()
177179

178180
last_processed_block = blocks[-1]['header']['number']
181+
if p_bar is not None:
182+
p_bar.update(last_processed_block-from_block+1)
179183
from_block = last_processed_block + 1
180184

181185
for block in blocks:

0 commit comments

Comments
 (0)