def sync(): Client(os.environ.get('SENTRY_DSN')) public_url = get_my_public_url() if public_url: click.echo(f"You have a public node url. ({public_url})") Node.broadcast(Node.post_node_endpoint, {'url': public_url}) Node.update() engine = db.engine if not engine.dialect.has_table(engine.connect(), Block.__tablename__): click.echo("You need to initialize. try `nekoyume init`.") return False while True: try: prev_id = Block.query.order_by(Block.id.desc()).first().id except AttributeError: prev_id = 0 Block.sync(click=click) try: if prev_id == Block.query.order_by(Block.id.desc()).first().id: click.echo("The blockchain is up to date.") time.sleep(15) except AttributeError: click.echo(("There is no well-connected node. " "please check you network.")) break
def get_nodes(): nodes = Node.query.filter( Node.last_connected_at >= datetime.datetime.now() - datetime.timedelta(60 * 3) ).order_by(Node.last_connected_at.desc()).limit(2500).all() public_url = get_my_public_url() if public_url: nodes.append(Node(url=public_url, last_connected_at=datetime.datetime.now())) return jsonify(nodes=[n.url for n in nodes])
def get_nodes(): nodes = Node.query.filter( Node.last_connected_at >= datetime.datetime.utcnow() - datetime.timedelta(minutes=60 * 3)).order_by( Node.last_connected_at.desc()).limit(2500).all() nodes = [n.url for n in nodes] public_url = get_my_public_url() if public_url and public_url not in nodes: nodes.append(public_url) return jsonify(nodes=nodes)
def sync(): public_url = get_my_public_url() if public_url: click.echo(f"You have a public node url. ({public_url})") Node.broadcast(Node.post_node_endpoint, {'url': public_url}) while True: try: prev_id = Block.query.order_by(Block.id.desc()).first().id except AttributeError: click.echo("You need to initialize. try `nekoyume init`.") break if not prev_id: click.echo("You need to initialize. try `nekoyume init`.") break Block.sync(click=click) if prev_id == Block.query.order_by(Block.id.desc()).first().id: click.echo("The blockchain is up to date.") time.sleep(15)
def get_public_url(): return jsonify( url=get_my_public_url() )