added continuous crawling

pull/617/head
Yhtyyar Sahatov 2022-03-10 18:25:21 +03:00
rodzic c1729dd836
commit 3a8d1bbd70
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
import json
import logging
from dataclasses import dataclass
import time
from typing import Any, Dict, List, Optional, Union
import web3
@ -288,7 +289,11 @@ def crawl(
pbar.set_description(f"Crawling blocks {from_block}-{to_block}")
while current_block <= to_block:
blockchain_block = web3.eth.block_number
if current_block > blockchain_block:
logger.info("Current block is greater than blockchain block, sleeping")
time.sleep(1)
continue
batch_end = min(current_block + batch_size, to_block)
logger.info(f"Crawling blocks {current_block}-{current_block + batch_size}")
events = []