Commit 8e974dd9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c8366907
......@@ -100,9 +100,6 @@ type Node struct {
// peer.linkMu and for some waiters chances are another .Link()
// already started redialing and they will have to wait again)
dialing *dialed
// // live connection pool that user provided back here via .PutConn()
// connPool []*Conn
}
// Len returns N(entries) in the table.
......@@ -454,59 +451,3 @@ func (p *Node) Dial(ctx context.Context) (*neonet.NodeLink, error) {
<-dialing.ready
return dialing.link, dialing.err
}
// XXX unused - kill?
// Conn returns conn to the peer. XXX -> DialConn ?
//
// If there is no link established - conn first dials peer (see Dial).
//
// For established link Conn either creates new connection over the link,
// XXX (currently inactive) or gets one from the pool of unused connections (see PutConn).
func (p *Node) Conn(ctx context.Context) (*neonet.Conn, error) {
var err error
/*
p.linkMu.Lock()
if l := len(p.connPool); l > 0 {
conn := p.connPool[l-1]
p.connPool = p.connPool[:l-1]
p.linkMu.Unlock()
return conn, nil
}
*/
// connection poll is empty - let's create new connection from .link
link := p.link
p.linkMu.Unlock()
// we might need to (re)dial
if link == nil {
link, err = p.Dial(ctx)
if err != nil {
return nil, err
}
}
return link.NewConn()
}
/*
// PutConn saves c in the pool of unused connections.
//
// Since connections saved into pool can be reused by other code, after
// PutConn call the caller must not use the connection directly.
//
// PutConn ignores connections not created for current peer link.
func (p *Peer) PutConn(c *Conn) {
p.linkMu.Lock()
// NOTE we can't panic on p.link != c.Dial() - reason is: p.link can change on redial
if p.link == c.Dial() {
p.connPool = append(p.connPool, c)
}
p.linkMu.Unlock()
}
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment