From c1079e1c29c8951b62a31467670f3307a3440cdb Mon Sep 17 00:00:00 2001 From: Derek Date: Tue, 7 Aug 2018 10:50:42 +0800 Subject: [PATCH] modify ns time to s (#1230) * fix the coinbase generate bug (#1136) * modify ns time to s --- p2p/peer.go | 8 ++++---- p2p/switch.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/p2p/peer.go b/p2p/peer.go index 2f442816..e35b633a 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -34,8 +34,8 @@ type PeerConfig struct { // DefaultPeerConfig returns the default config. func DefaultPeerConfig(config *cfg.P2PConfig) *PeerConfig { return &PeerConfig{ - HandshakeTimeout: time.Duration(config.HandshakeTimeout), // * time.Second, - DialTimeout: time.Duration(config.DialTimeout), // * time.Second, + HandshakeTimeout: time.Duration(config.HandshakeTimeout) * time.Second, // * time.Second, + DialTimeout: time.Duration(config.DialTimeout) * time.Second, // * time.Second, MConfig: connection.DefaultMConnConfig(), } } @@ -93,7 +93,7 @@ func newInboundPeerConn(conn net.Conn, ourNodePrivKey crypto.PrivKeyEd25519, con } func newPeerConn(rawConn net.Conn, outbound bool, ourNodePrivKey crypto.PrivKeyEd25519, config *PeerConfig) (*peerConn, error) { - rawConn.SetDeadline(time.Now().Add(config.HandshakeTimeout * time.Second)) + rawConn.SetDeadline(time.Now().Add(config.HandshakeTimeout)) conn, err := connection.MakeSecretConnection(rawConn, ourNodePrivKey) if err != nil { return nil, errors.Wrap(err, "Error creating peer") @@ -228,7 +228,7 @@ func createMConnection(conn net.Conn, p *Peer, reactorsByCh map[byte]Reactor, ch } func dial(addr *NetAddress, config *PeerConfig) (net.Conn, error) { - conn, err := addr.DialTimeout(config.DialTimeout * time.Second) + conn, err := addr.DialTimeout(config.DialTimeout) if err != nil { return nil, err } diff --git a/p2p/switch.go b/p2p/switch.go index 6a8b9445..0fa388e6 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -131,7 +131,7 @@ func (sw *Switch) AddBannedPeer(ip string) error { // NOTE: This performs a blocking handshake before the peer is added. // CONTRACT: If error is returned, peer is nil, and conn is immediately closed. func (sw *Switch) AddPeer(pc *peerConn) error { - peerNodeInfo, err := pc.HandshakeTimeout(sw.nodeInfo, time.Duration(sw.peerConfig.HandshakeTimeout*time.Second)) + peerNodeInfo, err := pc.HandshakeTimeout(sw.nodeInfo, time.Duration(sw.peerConfig.HandshakeTimeout)) if err != nil { return err } -- 2.11.0