diff options
author | Felix Lange <fjl@twurst.com> | 2015-05-14 09:04:04 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-05-14 20:53:29 +0800 |
commit | 691cb90284b9b63dc9c80bf0716ba35036ca78fe (patch) | |
tree | dd169615d057af4f35b619c44fb66219760749ba /p2p/peer.go | |
parent | 7efeb4bd9647b6ab5376e171c1ff7cb516da5698 (diff) | |
download | dexon-691cb90284b9b63dc9c80bf0716ba35036ca78fe.tar.gz dexon-691cb90284b9b63dc9c80bf0716ba35036ca78fe.tar.zst dexon-691cb90284b9b63dc9c80bf0716ba35036ca78fe.zip |
p2p: log remote reason when disconnect is requested
The returned reason is currently not used except for the log
message. This change makes the log messages a bit more useful.
The handshake code also returns the remote reason.
Diffstat (limited to 'p2p/peer.go')
-rw-r--r-- | p2p/peer.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/p2p/peer.go b/p2p/peer.go index ac691f2ce..c7ec08887 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -131,10 +131,11 @@ func (p *Peer) run() DiscReason { case err := <-p.protoErr: reason = discReasonForError(err) case reason = <-p.disc: + p.politeDisconnect(reason) + reason = DiscRequested } close(p.closed) - p.politeDisconnect(reason) p.wg.Wait() glog.V(logger.Debug).Infof("%v: Disconnected: %v\n", p, reason) return reason @@ -191,7 +192,7 @@ func (p *Peer) handle(msg Msg) error { // check errors because, the connection will be closed after it. rlp.Decode(msg.Payload, &reason) glog.V(logger.Debug).Infof("%v: Disconnect Requested: %v\n", p, reason[0]) - return DiscRequested + return reason[0] case msg.Code < baseProtocolLength: // ignore other base protocol messages return msg.Discard() |