Skip to content

Commit

Permalink
Fix subscription handling in SubstrateNodeDatasource
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizard1209 committed Dec 12, 2024
1 parent 86fd6fe commit c61cf00
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dipdup/datasources/substrate_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ async def _on_message(self, message: Message) -> None:
# NOTE: Save subscription id
if self._pending_subscription:
self._subscription_ids[data['result']] = self._pending_subscription
self._requests[data['id']] = (self._requests[data['id']][0], data)
self._requests[data['id']][0].set()

# NOTE: Possibly unreliable logic from evm_node, and possibly too time consuming for message handling
level = await self.get_head_level()
Expand Down Expand Up @@ -307,8 +309,7 @@ async def get_dev_metadata_version(self) -> MetadataVersion | None:
async def _subscribe(self, subscription: SubstrateNodeSubscription) -> None:
self._logger.debug('Subscribing to %s', subscription)
self._pending_subscription = subscription
response = await self._jsonrpc_request(subscription.method, params=[], ws=True)
raise RuntimeError('Subscription answered with %s', response)
await self._jsonrpc_request(subscription.method, params=[], ws=True)

async def _handle_subscription(self, subscription: SubstrateNodeSubscription, data: Any) -> None:
if isinstance(subscription, SubstrateNodeHeadSubscription):
Expand Down

0 comments on commit c61cf00

Please sign in to comment.