diff --git a/consensus/reactor.go b/consensus/reactor.go index 5c1b10c1c..37db31f55 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -24,7 +24,7 @@ const ( peerStateKey = "ConsensusReactor.peerState" - peerGossipSleepDuration = 50 * time.Millisecond // Time to sleep if there's nothing to send. + peerGossipSleepDuration = 1000 * time.Millisecond // Time to sleep if there's nothing to send. ) //----------------------------------------------------------------------------- @@ -262,6 +262,7 @@ OUTER_LOOP: // NOTE: if we or peer is at RoundStepCommit*, the round // won't necessarily match, but that's OK. if rs.ProposalBlockParts.HasHeader(prs.ProposalBlockParts) { + log.Debug("ProposalBlockParts matched", "blockParts", prs.ProposalBlockParts) if index, ok := rs.ProposalBlockParts.BitArray().Sub( prs.ProposalBlockBitArray).PickRandom(); ok { msg := &PartMessage{ @@ -278,6 +279,7 @@ OUTER_LOOP: // If height and round doesn't match, sleep. if rs.Height != prs.Height || rs.Round != prs.Round { + log.Debug("Height or Round mismatch, sleeping", "peerHeight", prs.Height, "peerRound", prs.Round) time.Sleep(peerGossipSleepDuration) continue OUTER_LOOP } diff --git a/p2p/connection.go b/p2p/connection.go index 9e247ba9c..6606eff4d 100644 --- a/p2p/connection.go +++ b/p2p/connection.go @@ -287,7 +287,7 @@ FOR_LOOP: } if err != nil { log.Warn("Connection failed @ sendRoutine", "connection", c, "error", err) - c.Stop() + c.stopForError(err) break FOR_LOOP } } @@ -382,7 +382,7 @@ FOR_LOOP: if err != nil { if atomic.LoadUint32(&c.stopped) != 1 { log.Warn("Connection failed @ recvRoutine", "connection", c, "error", err) - c.Stop() + c.stopForError(err) } break FOR_LOOP } @@ -400,8 +400,8 @@ FOR_LOOP: c.recvMonitor.Update(int(*n)) if *err != nil { if atomic.LoadUint32(&c.stopped) != 1 { - log.Warn(Fmt("%v failed @ recvRoutine", c)) - c.Stop() + log.Warn("Connection failed @ recvRoutine", "connection", c, "error", *err) + c.stopForError(*err) } break FOR_LOOP } diff --git a/p2p/switch.go b/p2p/switch.go index 4f68108e9..cf555667a 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -197,7 +197,7 @@ func (sw *Switch) Peers() IPeerSet { // Disconnect from a peer due to external error. // TODO: make record depending on reason. func (sw *Switch) StopPeerForError(peer *Peer, reason interface{}) { - log.Info(Fmt("- %v !! reason: %v", peer, reason)) + log.Info("Stopping peer for error", "peer", peer, "error", reason) sw.peers.Remove(peer) peer.stop() @@ -208,7 +208,7 @@ func (sw *Switch) StopPeerForError(peer *Peer, reason interface{}) { // Disconnect from a peer gracefully. // TODO: handle graceful disconnects. func (sw *Switch) StopPeerGracefully(peer *Peer) { - log.Info(Fmt("- %v", peer)) + log.Info("Stopping peer gracefully") sw.peers.Remove(peer) peer.stop()