def construct_ping_response(data): n = neighbor.load_nodes() response = {} response['type'] = 'ping_response' response['neighbors'] = [] for x in n: r = {} r['ip'] = x.ip r['port'] = x.port r['hash'] = x.hash response['neighbors'].append(r) print response return response
def ping(): neighbors = neighbor.load_nodes() for neigh in neighbors: ping_neighbor(neigh)
def closest(sought): n = neighbor.load_nodes() return closest_neighbor(n, sought)