aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-06-15 20:00:50 +0800
committerFelix Lange <fjl@twurst.com>2015-06-15 21:03:46 +0800
commit70da79f04c14e562c024e85c6b081b6b4b8e45ec (patch)
tree3db6b5c72a3f0667230c3475aae342b3ddb431ce /p2p
parent8dcbdcad0a92b053c7a5da2dc00b679c0044d050 (diff)
downloaddexon-70da79f04c14e562c024e85c6b081b6b4b8e45ec.tar
dexon-70da79f04c14e562c024e85c6b081b6b4b8e45ec.tar.gz
dexon-70da79f04c14e562c024e85c6b081b6b4b8e45ec.tar.bz2
dexon-70da79f04c14e562c024e85c6b081b6b4b8e45ec.tar.lz
dexon-70da79f04c14e562c024e85c6b081b6b4b8e45ec.tar.xz
dexon-70da79f04c14e562c024e85c6b081b6b4b8e45ec.tar.zst
dexon-70da79f04c14e562c024e85c6b081b6b4b8e45ec.zip
p2p: improve disconnect logging
Diffstat (limited to 'p2p')
-rw-r--r--p2p/peer.go11
-rw-r--r--p2p/peer_test.go2
2 files changed, 7 insertions, 6 deletions
diff --git a/p2p/peer.go b/p2p/peer.go
index 5489273bd..40466cf84 100644
--- a/p2p/peer.go
+++ b/p2p/peer.go
@@ -138,24 +138,27 @@ loop:
// A write finished. Allow the next write to start if
// there was no error.
if err != nil {
- glog.V(logger.Detail).Infof("%v: Write error: %v\n", p, err)
+ glog.V(logger.Detail).Infof("%v: write error: %v\n", p, err)
reason = DiscNetworkError
break loop
}
writeStart <- struct{}{}
case err := <-readErr:
if r, ok := err.(DiscReason); ok {
+ glog.V(logger.Debug).Infof("%v: remote requested disconnect: %v\n", p, r)
+ requested = true
reason = r
} else {
- glog.V(logger.Detail).Infof("%v: Read error: %v\n", p, err)
+ glog.V(logger.Detail).Infof("%v: read error: %v\n", p, err)
reason = DiscNetworkError
}
break loop
case err := <-p.protoErr:
reason = discReasonForError(err)
+ glog.V(logger.Debug).Infof("%v: protocol error: %v (%v)\n", p, err, reason)
break loop
case reason = <-p.disc:
- requested = true
+ glog.V(logger.Debug).Infof("%v: locally requested disconnect: %v\n", p, reason)
break loop
}
}
@@ -166,7 +169,6 @@ loop:
if requested {
reason = DiscRequested
}
- glog.V(logger.Debug).Infof("%v: Disconnected: %v\n", p, reason)
return reason
}
@@ -213,7 +215,6 @@ func (p *Peer) handle(msg Msg) error {
// This is the last message. We don't need to discard or
// 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 reason[0]
case msg.Code < baseProtocolLength:
// ignore other base protocol messages
diff --git a/p2p/peer_test.go b/p2p/peer_test.go
index 7b772e198..575d0ff79 100644
--- a/p2p/peer_test.go
+++ b/p2p/peer_test.go
@@ -121,7 +121,7 @@ func TestPeerDisconnect(t *testing.T) {
}
select {
case reason := <-disc:
- if reason != DiscQuitting {
+ if reason != DiscRequested {
t.Errorf("run returned wrong reason: got %v, want %v", reason, DiscRequested)
}
case <-time.After(500 * time.Millisecond):