Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
lint-roll
Browse files Browse the repository at this point in the history
  • Loading branch information
carver committed Jun 12, 2019
1 parent 39ecaca commit 773ce2c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions tests/core/p2p-proto/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ async def test_beam_syncer(
) as pausing_endpoint, AsyncioEndpoint.serve(gatherer_config) as gatherer_endpoint:

BeamPetersburgVM = pausing_vm_decorator(PetersburgVM, pausing_endpoint)

class BeamPetersburgTestChain(FakeAsyncChain):
vm_configuration = ((0, BeamPetersburgVM),)
network_id = 999
Expand Down
6 changes: 5 additions & 1 deletion trinity/sync/beam/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def __init__(
self.cancel_token,
)
self._state_downloader = BeamDownloader(db, peer_pool, event_bus, self.cancel_token)
self._data_hunter = StateDataHunter(self._state_downloader, event_bus, token=self.cancel_token)
self._data_hunter = StateDataHunter(
self._state_downloader,
event_bus,
token=self.cancel_token,
)

self._block_importer = BeamBlockImporter(chain, self._state_downloader, event_bus)
self._checkpoint_header_syncer = HeaderCheckpointSyncer(self._header_syncer)
Expand Down
22 changes: 17 additions & 5 deletions trinity/sync/beam/importer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
from functools import partial
import threading
from typing import (
Any,
Callable,
Expand All @@ -10,6 +9,7 @@
TypeVar,
)

from cancel_token import CancelToken
from eth.db.backends.base import BaseAtomicDB
from eth.rlp.blocks import BaseBlock
from eth.vm.state import BaseState
Expand Down Expand Up @@ -231,12 +231,16 @@ def _broadcast_import_complete(


class BlockImportServer(BaseService):
def __init__(self, event_bus: TrinityEventBusEndpoint, beam_chain: BaseAsyncChain, token=None):
def __init__(
self,
event_bus: TrinityEventBusEndpoint,
beam_chain: BaseAsyncChain,
token: CancelToken=None) -> None:
super().__init__(token=token)
self._event_bus = event_bus
self._beam_chain = beam_chain

async def _run(self):
async def _run(self) -> None:
self.run_daemon_task(self.serve(self._event_bus, self._beam_chain))
await self.cancellation()

Expand All @@ -260,9 +264,17 @@ async def serve(
perform_validation=True,
),
)
# Intentionally don't use .wait() because we want to hang the service from shutdown until block import is complete

# Intentionally don't use .wait() below, because we want to hang the service from
# shutting down until block import is complete.
await import_completion

if self.is_running:
_broadcast_import_complete(event_bus, event.block, event.broadcast_config(), import_completion)
_broadcast_import_complete( # type: ignore
event_bus,
event.block,
event.broadcast_config(),
import_completion,
)
else:
break

0 comments on commit 773ce2c

Please sign in to comment.