peer: rename peer.Connect to AssociateConnection

This commit is contained in:
Javed Khan 2016-10-21 22:57:29 +05:30 committed by Dave Collins
parent 99d04eea40
commit e3fd2f015c
4 changed files with 17 additions and 17 deletions

View File

@ -40,7 +40,7 @@ func mockRemotePeer() error {
// Create and start the inbound peer.
p := peer.NewInboundPeer(peerCfg)
p.Connect(conn)
p.AssociateConnection(conn)
}()
return nil
@ -91,7 +91,7 @@ func Example_newOutboundPeer() {
fmt.Printf("net.Dial: error %v\n", err)
return
}
p.Connect(conn)
p.AssociateConnection(conn)
// Wait for the verack message or timeout in case of failure.
select {

View File

@ -1846,9 +1846,9 @@ func (p *Peer) QueueInventory(invVect *wire.InvVect) {
p.outputInvChan <- invVect
}
// Connect uses the given conn to connect to the peer. Calling this function when
// the peer is already connected will have no effect.
func (p *Peer) Connect(conn net.Conn) {
// AssociateConnection associates the given conn to the peer. Calling this
// function when the peer is already connected will have no effect.
func (p *Peer) AssociateConnection(conn net.Conn) {
// Already connected?
if !atomic.CompareAndSwapInt32(&p.connected, 0, 1) {
return

View File

@ -251,13 +251,13 @@ func TestPeerConnection(t *testing.T) {
&conn{raddr: "10.0.0.2:8333"},
)
inPeer := peer.NewInboundPeer(peerCfg)
inPeer.Connect(inConn)
inPeer.AssociateConnection(inConn)
outPeer, err := peer.NewOutboundPeer(peerCfg, "10.0.0.2:8333")
if err != nil {
return nil, nil, err
}
outPeer.Connect(outConn)
outPeer.AssociateConnection(outConn)
for i := 0; i < 4; i++ {
select {
@ -277,13 +277,13 @@ func TestPeerConnection(t *testing.T) {
&conn{raddr: "10.0.0.2:8333"},
)
inPeer := peer.NewInboundPeer(peerCfg)
inPeer.Connect(inConn)
inPeer.AssociateConnection(inConn)
outPeer, err := peer.NewOutboundPeer(peerCfg, "10.0.0.2:8333")
if err != nil {
return nil, nil, err
}
outPeer.Connect(outConn)
outPeer.AssociateConnection(outConn)
for i := 0; i < 4; i++ {
select {
@ -396,7 +396,7 @@ func TestPeerListeners(t *testing.T) {
&conn{raddr: "10.0.0.2:8333"},
)
inPeer := peer.NewInboundPeer(peerCfg)
inPeer.Connect(inConn)
inPeer.AssociateConnection(inConn)
peerCfg.Listeners = peer.MessageListeners{
OnVerAck: func(p *peer.Peer, msg *wire.MsgVerAck) {
@ -408,7 +408,7 @@ func TestPeerListeners(t *testing.T) {
t.Errorf("NewOutboundPeer: unexpected err %v\n", err)
return
}
outPeer.Connect(outConn)
outPeer.AssociateConnection(outConn)
for i := 0; i < 2; i++ {
select {
@ -550,8 +550,8 @@ func TestOutboundPeer(t *testing.T) {
}
// Test trying to connect twice.
p.Connect(c)
p.Connect(c)
p.AssociateConnection(c)
p.AssociateConnection(c)
disconnected := make(chan struct{})
go func() {
@ -604,7 +604,7 @@ func TestOutboundPeer(t *testing.T) {
t.Errorf("NewOutboundPeer: unexpected err - %v\n", err)
return
}
p1.Connect(c1)
p1.AssociateConnection(c1)
// Test update latest block
latestBlockHash, err := chainhash.NewHashFromStr("1a63f9cdff1752e6375c8c76e543a71d239e1a2e5c6db1aa679")
@ -634,7 +634,7 @@ func TestOutboundPeer(t *testing.T) {
t.Errorf("NewOutboundPeer: unexpected err - %v\n", err)
return
}
p2.Connect(c2)
p2.AssociateConnection(c2)
// Test PushXXX
var addrs []*wire.NetAddress

View File

@ -1644,7 +1644,7 @@ func (s *server) listenHandler(listener net.Listener) {
sp := newServerPeer(s, false)
sp.Peer = peer.NewInboundPeer(newPeerConfig(sp))
go s.peerDoneHandler(sp)
sp.Connect(conn)
sp.AssociateConnection(conn)
}
s.wg.Done()
srvrLog.Tracef("Listener handler done for %s", listener.Addr())
@ -1740,7 +1740,7 @@ func (s *server) establishConn(sp *serverPeer) error {
if err != nil {
return err
}
sp.Connect(conn)
sp.AssociateConnection(conn)
s.addrManager.Attempt(sp.NA())
return nil
}