Skip to content

Commit 8d891dd

Browse files
committed
get_block_metadata in alpha to tao shovel
1 parent 2e8b3d3 commit 8d891dd

File tree

1 file changed

+5
-13
lines changed
  • scraper_service/shovel_alpha_to_tao

1 file changed

+5
-13
lines changed

scraper_service/shovel_alpha_to_tao/main.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
table_exists,
77
)
88
from shared.exceptions import DatabaseConnectionError, ShovelProcessingError
9+
from shared.block_metadata import get_block_metadata
910
import logging
1011

1112

@@ -41,20 +42,11 @@ def do_process_block(self, n):
4142
raise DatabaseConnectionError(f"Failed to create/check table: {str(e)}")
4243

4344
try:
44-
block_hash = substrate.get_block_hash(n)
45-
block_timestamp = int(
46-
substrate.query(
47-
"Timestamp",
48-
"Now",
49-
block_hash=block_hash,
50-
).serialize()
51-
/ 1000
52-
)
45+
block_timestamp, block_hash = get_block_metadata(n)
46+
if block_timestamp == 0 and n != 0:
47+
raise ShovelProcessingError(f"Invalid block timestamp (0) for block {n}")
5348
except Exception as e:
54-
raise ShovelProcessingError(f"Failed to get block timestamp from substrate: {str(e)}")
55-
56-
if block_timestamp == 0 and n != 0:
57-
raise ShovelProcessingError(f"Invalid block timestamp (0) for block {n}")
49+
raise ShovelProcessingError(f"Failed to get block metadata: {str(e)}")
5850

5951
try:
6052
# Get list of active subnets

0 commit comments

Comments
 (0)