From cfb4a40855aae9937f7179cacf1c7090e49f22c2 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Mon, 4 May 2015 22:21:07 -0700 Subject: [PATCH] adding more debug logs --- .gitignore | 1 + config/config.go | 2 +- consensus/reactor.go | 21 ++++++++++++++++++++- p2p/connection.go | 14 ++++++++------ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 760c8cf71..36b24c7eb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build/* rpc/test/.tendermint .debora .tendermint +remote_dump diff --git a/config/config.go b/config/config.go index f11bf30dc..7ae4e3117 100644 --- a/config/config.go +++ b/config/config.go @@ -36,7 +36,7 @@ var defaultConfig = `# This is a TOML config file. # For more information, see https://github.com/toml-lang/toml Moniker = "anonymous" -Network = "tendermint_testnet4.1" +Network = "tendermint_testnet4.2" ListenAddr = "0.0.0.0:46656" # First node to connect to. Command-line overridable. SeedNode = "" diff --git a/consensus/reactor.go b/consensus/reactor.go index 3926bfd52..31171e526 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -418,6 +418,10 @@ OUTER_LOOP: } func (conR *ConsensusReactor) gossipVotesRoutine(peer *p2p.Peer, ps *PeerState) { + + // Simple hack to throttle logs upon sleep. + var sleeping = 0 + OUTER_LOOP: for { // Manage disconnects from self or peer. @@ -428,6 +432,13 @@ OUTER_LOOP: rs := conR.conS.GetRoundState() prs := ps.GetRoundState() + switch sleeping { + case 1: // First sleep + sleeping = 2 + case 2: // No more sleep + sleeping = 0 + } + trySendVote := func(voteSet *VoteSet, peerVoteSet BitArray) (sent bool) { if prs.Height == voteSet.Height() { // Initialize Prevotes/Precommits/Commits if needed @@ -547,7 +558,15 @@ OUTER_LOOP: } } - // We sent nothing. Sleep... + if sleeping == 0 { + // We sent nothing. Sleep... + sleeping = 1 + log.Debug("No votes to send, sleeping", "peer", peer) + } else if sleeping == 2 { + // Continued sleep... + sleeping = 1 + } + time.Sleep(peerGossipSleepDuration) continue OUTER_LOOP } diff --git a/p2p/connection.go b/p2p/connection.go index 919f71aa9..783cedeed 100644 --- a/p2p/connection.go +++ b/p2p/connection.go @@ -192,13 +192,15 @@ func (c *MConnection) Send(chId byte, msg interface{}) bool { } success := channel.sendBytes(binary.BinaryBytes(msg)) - - // Wake up sendRoutine if necessary - select { - case c.send <- struct{}{}: - default: + if success { + // Wake up sendRoutine if necessary + select { + case c.send <- struct{}{}: + default: + } + } else { + log.Warn("Send failed", "channel", chId, "connection", c, "msg", msg) } - return success }