Пример #1
0
 async def peerCount(self) -> str:
     """
     Return the number of peers that are currently connected to the node
     """
     response = await self.event_bus.request(
         PeerCountRequest(), TO_NETWORKING_BROADCAST_CONFIG)
     return hex(response.peer_count)
Пример #2
0
    async def get_node_stats(self) -> EthstatsData:
        response: PeerCountResponse = await self.context.event_bus.request(
            PeerCountRequest())

        return {
            'active': True,
            'peers': response.peer_count,
        }
Пример #3
0
 async def _periodically_report_stats(self) -> None:
     while self.is_operational:
         try:
             response = await asyncio.wait_for(
                 self.event_bus.request(PeerCountRequest()),
                 timeout=1.0
             )
             self.logger.info("CONNECTED PEERS: %s", response.peer_count)
         except asyncio.TimeoutError:
             self.logger.warning("TIMEOUT: Waiting on PeerPool to boot")
         await asyncio.sleep(5)
Пример #4
0
    async def get_node_stats(self) -> EthstatsData:

        try:
            peer_count = (await self.wait(self.context.event_bus.request(
                PeerCountRequest()),
                                          timeout=0.5)).peer_count
        except TimeoutError:
            self.logger.warning(
                "Timeout: PeerPool did not answer PeerCountRequest")
            peer_count = 0

        return {
            'active': True,
            'peers': peer_count,
        }
Пример #5
0
    async def get_node_stats(self) -> EthstatsData:
        '''Getter for data that should be sent periodically.'''
        try:
            peer_count = (await self.wait(
                self.context.event_bus.request(PeerCountRequest()),
                timeout=0.5
            )).peer_count
        except TimeoutError:
            self.logger.warning("Timeout: PeerPool did not answer PeerCountRequest")
            peer_count = 0

        return {
            'active': True,
            'uptime': 100,
            'peers': peer_count,
        }
Пример #6
0
 async def peerCount(self) -> str:
     """
     Return the number of peers that are currently connected to the node
     """
     response = await self._event_bus.request(PeerCountRequest())
     return hex(response.peer_count)