checking for None for checkpoint

pull/617/head
Yhtyyar Sahatov 2022-04-05 14:01:38 +03:00
rodzic 721fd61e02
commit 8594ba9bf5
2 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -76,7 +76,7 @@ def handle_materialize(args: argparse.Namespace) -> None:
moonstream_datastore, args.blockchain.value
)
logger.info(f"Last saved block: {last_saved_block}")
if last_saved_block >= bounds.starting_block:
if last_saved_block and last_saved_block >= bounds.starting_block:
logger.info(
f"Skipping blocks {bounds.starting_block}-{last_saved_block}, starting from {last_saved_block + 1}"
)

Wyświetl plik

@ -380,7 +380,9 @@ def insert_events(
conn.commit()
def get_last_saved_block(conn: sqlite3.Connection, blockchain_type: str) -> int:
def get_last_saved_block(
conn: sqlite3.Connection, blockchain_type: str
) -> Optional[int]:
"""
Returns the last block number that was saved to the database.
"""
@ -390,8 +392,6 @@ def get_last_saved_block(conn: sqlite3.Connection, blockchain_type: str) -> int:
cur.execute(query)
result = cur.fetchone()
if result is None:
return 0
return result[0]