def wss_handshake(rpc): """ Create a websocket handshake """ while True: nodes = json_ipc(doc="nodes.txt") try: rpc.close() except Exception: pass try: shuffle(nodes) node = nodes[0] start = time.time() rpc = wss(node, timeout=4) if time.time() - start < 3: # print(node) break except Exception: nodes = [n for n in nodes if n != node] if len(nodes) < 7: nodes = bitshares_nodes() json_ipc(doc="nodes.txt", text=json_dumps(nodes)) return rpc
def wss_handshake(storage, node): # DONE """ Create a websocket handshake """ start = time() handshake_max = min(9.999, 10 * storage["mean_ping"]) rpc = wss(node, timeout=handshake_max) handshake_latency = min(9.999, (time() - start)) if 0 > handshake_latency > handshake_max: raise ValueError("slow handshake", handshake_latency) sleep(2) return rpc, handshake_latency, handshake_max
def wss_handshake(): """ Create a websocket handshake """ while True: nodes = bitshares_nodes() shuffle(nodes) node = nodes[0] start = time.time() rpc = wss(node, timeout=3) if time.time() - start < 3: break return rpc
def wss_handshake(node): global ws ws = wss(node, timeout=5)
def wss_handshake(node): """ Create a websocket connection to a BitShares public RPC node """ return wss(node, timeout=TIMEOUT)