make Dial block until the search finishes, and use it as such

This commit is contained in:
Arceliar 2019-06-28 18:42:31 -05:00
parent 29a0f8b572
commit 5df110ac79
5 changed files with 111 additions and 156 deletions

View file

@ -14,6 +14,8 @@ type Dialer struct {
core *Core
}
// TODO DialContext that allows timeouts/cancellation, Dial should just call this with no timeout set in the context
// Dial opens a session to the given node. The first paramter should be "nodeid"
// and the second parameter should contain a hexadecimal representation of the
// target node ID.
@ -58,5 +60,8 @@ func (d *Dialer) Dial(network, address string) (*Conn, error) {
// NodeID parameters.
func (d *Dialer) DialByNodeIDandMask(nodeID, nodeMask *crypto.NodeID) (*Conn, error) {
conn := newConn(d.core, nodeID, nodeMask, nil)
if err := conn.search(); err != nil {
return nil, err
}
return conn, nil
}