Merge pull request #2 from logos-blockchain/logos-blockchain-node-api-update

Updated logos-blockchain node api url path and deserialization
This commit is contained in:
Petar Radovic 2026-01-30 13:27:04 +01:00 committed by GitHub
commit 02658ac293
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -21,4 +21,4 @@ GET {{host}}/cryptarchia/blocks?slot_from=0&slot_to=10
###
GET {{host}}/cryptarchia/blocks/stream
GET {{host}}/cryptarchia/events/blocks/stream

View File

@ -1,3 +1,4 @@
import json
import logging
from typing import TYPE_CHECKING, AsyncIterator, List, Optional
from urllib.parse import urljoin, urlunparse
@ -24,7 +25,7 @@ class HttpNodeApi(NodeApi):
ENDPOINT_INFO = "cryptarchia/info"
ENDPOINT_TRANSACTIONS = "cryptarchia/transactions"
ENDPOINT_BLOCKS = "cryptarchia/blocks"
ENDPOINT_BLOCKS_STREAM = "cryptarchia/blocks/stream"
ENDPOINT_BLOCKS_STREAM = "cryptarchia/events/blocks/stream"
def __init__(self, settings: "NBESettings"):
self.host: str = settings.node_api_host
@ -89,8 +90,9 @@ class HttpNodeApi(NodeApi):
if not line:
continue
try:
block = BlockSerializer.model_validate_json(line)
except ValidationError as error:
event = json.loads(line)
block = BlockSerializer.model_validate(event["block"])
except (ValidationError, KeyError, json.JSONDecodeError) as error:
logger.exception(error)
continue