func (p *Peer) HandshakeTimeout(ourNodeInfo *NodeInfo, timeout time.Duration) error {
	// Set deadline for handshake so we don't block forever on conn.ReadFull
	p.conn.SetDeadline(time.Now().Add(timeout))

	var peerNodeInfo = new(NodeInfo)
	var err1 error
	var err2 error
	cmn.Parallel(
		func() {
			var n int
			wire.WriteBinary(ourNodeInfo, p.conn, &n, &err1)
		},
		func() {
			var n int
			wire.ReadBinary(peerNodeInfo, p.conn, maxNodeInfoSize, &n, &err2)
			log.Notice("Peer handshake", "peerNodeInfo", peerNodeInfo)
		})
	if err1 != nil {
		return errors.Wrap(err1, "Error during handshake/write")
	}
	if err2 != nil {
		return errors.Wrap(err2, "Error during handshake/read")
	}

	if p.config.AuthEnc {
		// Check that the professed PubKey matches the sconn's.
		if !peerNodeInfo.PubKey.Equals(p.PubKey()) {
			return fmt.Errorf("Ignoring connection with unmatching pubkey: %v vs %v",
				peerNodeInfo.PubKey, p.PubKey())
		}
	}

	// Remove deadline
	p.conn.SetDeadline(time.Time{})

	peerNodeInfo.RemoteAddr = p.Addr().String()

	p.NodeInfo = peerNodeInfo
	p.Key = peerNodeInfo.PubKey.KeyString()

	return nil
}
func (p *Peer) HandshakeTimeout(ourNodeInfo *NodeInfo, timeout time.Duration) error {
	
	p.conn.SetDeadline(time.Now().Add(timeout))

	var peerNodeInfo = new(NodeInfo)
	var err1 error
	var err2 error
	cmn.Parallel(
		func() {
			var n int
			wire.WriteBinary(ourNodeInfo, p.conn, &n, &err1)
		},
		func() {
			var n int
			wire.ReadBinary(peerNodeInfo, p.conn, maxNodeInfoSize, &n, &err2)
			log.Notice("Peer handshake", "peerNodeInfo", peerNodeInfo)
		})
	if err1 != nil {
		return errors.Wrap(err1, "Error during handshake/write")
	}
	if err2 != nil {
		return errors.Wrap(err2, "Error during handshake/read")
	}

	if p.config.AuthEnc {
		
		if !peerNodeInfo.PubKey.Equals(p.PubKey()) {
			return fmt.Errorf("Ignoring connection with unmatching pubkey: %v vs %v",
				peerNodeInfo.PubKey, p.PubKey())
		}
	}

	
	p.conn.SetDeadline(time.Time{})

	peerNodeInfo.RemoteAddr = p.Addr().String()

	p.NodeInfo = peerNodeInfo
	p.Key = peerNodeInfo.PubKey.KeyString()

	return nil
}
func ( p * Peer ) HandshakeTimeout ( ourNodeInfo * NodeInfo , timeout time . Duration ) error { // Set deadline for handshake so we don't block forever on conn.ReadFull p . conn . SetDeadline ( time . Now ( ) . Add ( timeout ) ) var peerNodeInfo = new ( NodeInfo ) var err1 error var err2 error cmn . Parallel ( func ( ) { var n int wire . WriteBinary ( ourNodeInfo , p . conn , & n , & err1 ) } , func ( ) { var n int wire . ReadBinary ( peerNodeInfo , p . conn , maxNodeInfoSize , & n , & err2 ) log . Notice ( " " , " " , peerNodeInfo ) } ) if err1 != nil { return errors . Wrap ( err1 , " " ) } if err2 != nil { return errors . Wrap ( err2 , " " ) } if p . config . AuthEnc { // Check that the professed PubKey matches the sconn's. if ! peerNodeInfo . PubKey . Equals ( p . PubKey ( ) ) { return fmt . Errorf ( " " , peerNodeInfo . PubKey , p . PubKey ( ) ) } } // Remove deadline p . conn . SetDeadline ( time . Time { } ) peerNodeInfo . RemoteAddr = p . Addr ( ) . String ( ) p . NodeInfo = peerNodeInfo p . Key = peerNodeInfo . PubKey . KeyString ( ) return nil }
// HandshakeTimeout performs a handshake between a given node and the peer.
// NOTE: blocking
HandshakeTimeout performs a handshake between a given node and the peer . NOTE : blocking