diff --git a/datasets/nfts/nfts/cli.py b/datasets/nfts/nfts/cli.py index c0ae388f..bbc8de06 100644 --- a/datasets/nfts/nfts/cli.py +++ b/datasets/nfts/nfts/cli.py @@ -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}" ) diff --git a/datasets/nfts/nfts/datastore.py b/datasets/nfts/nfts/datastore.py index db994957..566fa8da 100644 --- a/datasets/nfts/nfts/datastore.py +++ b/datasets/nfts/nfts/datastore.py @@ -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]