def _maintain_peers(self): while True: try: for peer_metadata in self._all_peers(): if peer_metadata.peers_needs_refresh: f = peer_metadata.stub.GetKnownPeers.future( qrl_pb2.GetKnownPeersReq(), timeout=PeerManager.TIMEOUT_SECS) f.pm = peer_metadata f.add_done_callback(self._add_peers_callback) else: f = peer_metadata.stub.GetNodeState.future( qrl_pb2.GetNodeStateReq(), timeout=PeerManager.TIMEOUT_SECS) f.pm = peer_metadata f.add_done_callback(self._update_state_callback) # FIXME: QRLNode should probably depend on this tmp = [] for peer_metadata in self.stable_peers(): addr = peer_metadata.conn_addr.split(':')[0] tmp.append(addr) # self.qrlnode.update_peer_addresses(tmp) sleep(self.REFRESH_CYCLE_SECS) self.recycle() except Exception as e: logger.exception(e)
def state(ctx): """ Shows Information about a Node's State """ stub = ctx.obj.get_stub_public_api() nodeStateResp = stub.GetNodeState(qrl_pb2.GetNodeStateReq()) if ctx.obj.json: click.echo(MessageToJson(nodeStateResp, sort_keys=True)) else: click.echo(nodeStateResp)
def state(ctx): """ Shows Information about a Node's State """ channel = grpc.insecure_channel(ctx.obj.node_public_address) stub = qrl_pb2_grpc.PublicAPIStub(channel) nodeStateResp = stub.GetNodeState(qrl_pb2.GetNodeStateReq()) if ctx.obj.json: click.echo(MessageToJson(nodeStateResp)) else: click.echo(nodeStateResp)
def state(ctx): """ Shows Information about a Node's State """ stub = ctx.obj.get_stub_public_api() nodeStateResp = stub.GetNodeState(qrl_pb2.GetNodeStateReq()) hstr_block_last_hash = bin2hstr( nodeStateResp.info.block_last_hash).encode() if ctx.obj.output_json: jsonMessage = MessageToDict(nodeStateResp) jsonMessage['info']['blockLastHash'] = hstr_block_last_hash click.echo(json.dumps(jsonMessage, indent=2, sort_keys=True)) else: nodeStateResp.info.block_last_hash = hstr_block_last_hash click.echo(nodeStateResp)
def state_check(): public_api_addresses = mocknet.public_addresses for public_api_address in public_api_addresses: channel_public = grpc.insecure_channel(public_api_address) stub = qrl_pb2_grpc.PublicAPIStub(channel_public) # TODO: Check coins emitted, coins total supply, epoch, block_last_reward # response = stub.GetStats(request=qrl_pb2.GetStatsReq()) response = stub.GetNodeState(request=qrl_pb2.GetNodeStateReq()) if response.info.block_height != LAST_BLOCK_NUMBER: raise Exception('Expected Blockheight %s \n Found blockheight %s', LAST_BLOCK_NUMBER, response.info.block_height) if response.info.block_last_hash != bytes(hstr2bin(LAST_BLOCK_HEADERHASH)): raise Exception('Last Block Headerhash mismatch\n' 'Expected : %s\n', bin2hstr(response.info.block_last_hash), 'Found : %s ', LAST_BLOCK_HEADERHASH) return True
def get_node_info(self): return self._public_stub.GetNodeState(qrl_pb2.GetNodeStateReq())