Skip to content

Commit 2a4bcf1

Browse files
committed
Fix genesis block parsing
1 parent 6187de1 commit 2a4bcf1

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

app/parser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,7 @@ async def parse_block(height: int):
226226

227227
block_data = block_data_result["result"]
228228

229-
transactions_data = await parse_transactions(
230-
[] if height == 0 else block_data["tx"],
231-
)
229+
transactions_data = await parse_transactions(block_data["tx"])
232230

233231
result["transactions"] = transactions_data["transactions"]
234232
result["outputs"] = transactions_data["outputs"]

app/sync/chain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ async def sync_chain():
189189
latest = await process_block(session, block_data)
190190

191191
await session.commit()
192+
print("Added genesis block")
192193

193194
while True:
194195
latest_hash_data = await make_request(

app/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import datetime, timezone, UTC
2-
from typing import Sequence
2+
from collections.abc import Sequence
3+
from typing import Any
34
import math
45

56
from app import constants
@@ -16,23 +17,25 @@ def to_timestamp(date: datetime | None) -> int | None:
1617

1718

1819
# Helper function for pagination
19-
def pagination(page, size=constants.DEFAULT_PAGINATION_SIZE):
20+
def pagination(page: int, size: int = constants.DEFAULT_PAGINATION_SIZE):
2021
"""limit, offset = pagination(:page, :page_size)"""
2122
offset = (size * page) - size
2223

2324
return size, offset
2425

2526

2627
# Helper function to make pagination dict for api
27-
def pagination_dict(total, page, limit):
28+
def pagination_dict(total: int, page: int, limit: int) -> dict[str, int]:
2829
return {
2930
"pages": math.ceil(total / limit),
3031
"total": total,
3132
"page": page,
3233
}
3334

3435

35-
def paginated_response(items: Sequence, total: int, page: int, limit: int) -> dict:
36+
def paginated_response(
37+
items: Sequence[Any], total: int, page: int, limit: int
38+
) -> dict[str, Any]:
3639
return {
3740
"pagination": pagination_dict(total, page, limit),
3841
"list": items,

0 commit comments

Comments
 (0)