def peer_connect(self, dstaddr, dstport, net='regtest'):
    assert (not self.is_connected)
    self.dstaddr = dstaddr
    self.dstport = dstport
    self.on_connection_send_msg = None
    self.recvbuf = b''
    self.network = net
    logger.debug(('Connecting to BitcoinSN Node: %s:%d' % (self.dstaddr, self.dstport)))
    loop = NetworkThread.network_event_loop
    conn_gen_unsafe = loop.create_connection((lambda : self), host=self.dstaddr, port=self.dstport)
    conn_gen = (lambda : loop.call_soon_threadsafe(loop.create_task, conn_gen_unsafe))
    return conn_gen
def peer_connect(self, dstaddr, dstport, net='regtest'):
    assert (not self.is_connected)
    self.dstaddr = dstaddr
    self.dstport = dstport
    self.on_connection_send_msg = None
    self.recvbuf = b
    self.network = net
    logger.debug(('Connecting to BitcoinSN Node: %s:%d' % (self.dstaddr, self.dstport)))
    loop = NetworkThread.network_event_loop
    conn_gen_unsafe = loop.create_connection((lambda : self), host=self.dstaddr, port=self.dstport)
    conn_gen = (lambda : loop.call_soon_threadsafe(loop.create_task, conn_gen_unsafe))
    return conn_gen