Пример #1
0
    async def _setup_for_next_gap(self) -> None:
        gap_start, gap_end = self._get_next_gap()
        fill_start = BlockNumber(max(
            gap_start,
            gap_end - self._max_backfill_block_bodies_at_once,
        ))
        start_num = BlockNumber(fill_start - 1)
        _starting_tip = await self._db.coro_get_canonical_block_header_by_number(start_num)

        if self._pauser.is_paused:
            # If the syncer was paused while we were busy setting it up throw the current setup
            # away. A new setup will be performed as soon as `resume()` was called again.
            raise ValidationError("Syncer was paused by the user")

        async def _get_launch_header() -> BlockHeaderAPI:
            return _starting_tip

        self.logger.debug("Starting to sync missing blocks from #%s to #%s", fill_start, gap_end)

        self._body_syncer = FastChainBodySyncer(
            self._chain,
            self._db,
            self._peer_pool,
            DatabaseBlockRangeHeaderSyncer(self._db, (fill_start, gap_end,)),
            launch_header_fn=_get_launch_header,
            should_skip_header_fn=body_for_header_exists(self._db, self._chain)
        )
        self._body_syncer.logger = self.logger
Пример #2
0
    async def _setup_for_next_gap(self) -> None:
        gap_start, gap_end = self._get_next_gap()
        start_num = BlockNumber(gap_start - 1)
        _starting_tip = await self._db.coro_get_canonical_block_header_by_number(start_num)

        async def _get_launch_header() -> BlockHeaderAPI:
            return _starting_tip

        self.logger.debug("Starting to sync missing blocks from #%s to #%s", gap_start, gap_end)

        self._body_syncer = FastChainBodySyncer(
            self._chain,
            self._db,
            self._peer_pool,
            DatabaseBlockRangeHeaderSyncer(self._db, (gap_start, gap_end,)),
            launch_header_fn=_get_launch_header,
            should_skip_header_fn=body_for_header_exists(self._db, self._chain)
        )