Example #1
0
 async def fetch_headers(self, start_block: int, peer: LESPeer) -> List[BlockHeader]:
     for i in range(self.max_consecutive_timeouts):
         try:
             return await peer.fetch_headers_starting_at(start_block, self.cancel_token)
         except TimeoutError:
             self.logger.info(
                 "Timeout when fetching headers from %s (attempt %d of %d)",
                 peer, i + 1, self.max_consecutive_timeouts)
             # TODO: Figure out what's a good value to use here.
             await asyncio.sleep(0.5)
     raise TooManyTimeouts()
Example #2
0
    async def fetch_headers(self, start_block: int, peer: LESPeer) -> List[BlockHeader]:
        if start_block == GENESIS_BLOCK_NUMBER:
            raise ValidationError("Must not attempt to download genesis header")

        for i in range(self.max_consecutive_timeouts):
            try:
                return await self._fetch_headers_starting_at(peer, start_block)
            except TimeoutError:
                self.logger.info(
                    "Timeout when fetching headers from %s (attempt %d of %d)",
                    peer, i + 1, self.max_consecutive_timeouts)
                # TODO: Figure out what's a good value to use here.
                await asyncio.sleep(0.5)
        raise TooManyTimeouts()