X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=p2p%2Fpeer.go;h=e239e372a95bddab4d7c934d3348082c643d3a7b;hb=a177b8b4f2828248c5bf34561b877c2578b77dd1;hp=11641b8c1d607473ac524aead24cf4fe92573331;hpb=627c2746596ce7cf687cc6afd7c93754510eea63;p=bytom%2Fvapor.git diff --git a/p2p/peer.go b/p2p/peer.go index 11641b8c..e239e372 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -9,7 +9,6 @@ import ( "github.com/btcsuite/go-socks/socks" "github.com/pkg/errors" log "github.com/sirupsen/logrus" - "github.com/tendermint/go-crypto" "github.com/tendermint/go-wire" cmn "github.com/tendermint/tmlibs/common" "github.com/tendermint/tmlibs/flowrate" @@ -17,6 +16,7 @@ import ( cfg "github.com/vapor/config" "github.com/vapor/consensus" "github.com/vapor/p2p/connection" + "github.com/vapor/p2p/signlib" ) // peerConn contains the raw connection and its config. @@ -76,7 +76,7 @@ func newPeer(pc *peerConn, nodeInfo *NodeInfo, reactorsByCh map[byte]Reactor, ch p := &Peer{ peerConn: pc, NodeInfo: nodeInfo, - Key: nodeInfo.PubKey.KeyString(), + Key: nodeInfo.PubKey, isLAN: isLAN, } p.mconn = createMConnection(pc.conn, p, reactorsByCh, chDescs, onPeerError, pc.config.MConfig) @@ -84,7 +84,7 @@ func newPeer(pc *peerConn, nodeInfo *NodeInfo, reactorsByCh map[byte]Reactor, ch return p } -func newOutboundPeerConn(addr *NetAddress, ourNodePrivKey crypto.PrivKeyEd25519, config *PeerConfig) (*peerConn, error) { +func newOutboundPeerConn(addr *NetAddress, ourNodePrivKey signlib.PrivKey, config *PeerConfig) (*peerConn, error) { conn, err := dial(addr, config) if err != nil { return nil, errors.Wrap(err, "Error dial peer") @@ -98,11 +98,11 @@ func newOutboundPeerConn(addr *NetAddress, ourNodePrivKey crypto.PrivKeyEd25519, return pc, nil } -func newInboundPeerConn(conn net.Conn, ourNodePrivKey crypto.PrivKeyEd25519, config *cfg.P2PConfig) (*peerConn, error) { +func newInboundPeerConn(conn net.Conn, ourNodePrivKey signlib.PrivKey, config *cfg.P2PConfig) (*peerConn, error) { return newPeerConn(conn, false, ourNodePrivKey, DefaultPeerConfig(config)) } -func newPeerConn(rawConn net.Conn, outbound bool, ourNodePrivKey crypto.PrivKeyEd25519, config *PeerConfig) (*peerConn, error) { +func newPeerConn(rawConn net.Conn, outbound bool, ourNodePrivKey signlib.PrivKey, config *PeerConfig) (*peerConn, error) { rawConn.SetDeadline(time.Now().Add(config.HandshakeTimeout)) conn, err := connection.MakeSecretConnection(rawConn, ourNodePrivKey) if err != nil { @@ -195,8 +195,8 @@ func (p *Peer) IsLAN() bool { } // PubKey returns peer's public key. -func (p *Peer) PubKey() crypto.PubKeyEd25519 { - return p.conn.(*connection.SecretConnection).RemotePubKey() +func (p *Peer) PubKey() string { + return p.conn.(*connection.SecretConnection).RemotePubKey().String() } // Send msg to the channel identified by chID byte. Returns false if the send