def dbcall(): with self.db.open_session() as sess: node_state = sess.query(db.NodeState)\ .filter(db.NodeState.key == NSK_DATASTORE_SIZE)\ .first() if node_state: datastore_size = int(node_state.value) else: datastore_size = 0 max_distance = sess.query(db.DataBlock.distance)\ .order_by(db.DataBlock.distance.desc())\ .first() if max_distance: max_distance = max_distance[0] else: max_distance = b"" if log.isEnabledFor(logging.INFO): log.info("max_distance=[{}]."\ .format(hex_string(max_distance))) return datastore_size, max_distance
def do_findnode(self, arg): "[ID] find the node with id." node_id, significant_bits = decode_key(arg) if significant_bits: self.writeln("Won't FindNode for incomplete key.") return start = datetime.today() result = yield from self.peer.engine.tasks.send_find_node(node_id) diff = datetime.today() - start self.writeln("send_find_node(..) took: {}.".format(diff)) for r in result: self.writeln("nid[{}] FOUND: {:22} id=[{}] diff=[{}]"\ .format(r.id, r.address, hex_string(r.node_id),\ hex_string(\ calc_raw_distance(\ r.node_id, node_id))))