Browse Source

Log which commits are being sent for catchup

pull/9/head
Jae Kwon 10 years ago
parent
commit
2ca882a9b6
2 changed files with 18 additions and 13 deletions
  1. +7
    -3
      consensus/reactor.go
  2. +11
    -10
      p2p/connection.go

+ 7
- 3
consensus/reactor.go View File

@ -396,26 +396,30 @@ OUTER_LOOP:
// which contains commit signatures for prs.Height. // which contains commit signatures for prs.Height.
header, validation := conR.conS.LoadHeaderValidation(prs.Height + 1) header, validation := conR.conS.LoadHeaderValidation(prs.Height + 1)
size := uint(len(validation.Commits)) size := uint(len(validation.Commits))
log.Debug("Loaded HeaderValidation for catchup", "height", prs.Height+1, "header", header, "validation", validation, "size", size)
// Initialize Commits if needed // Initialize Commits if needed
ps.EnsureVoteBitArrays(prs.Height, size) ps.EnsureVoteBitArrays(prs.Height, size)
index, ok := validation.BitArray().Sub(prs.Commits).PickRandom() index, ok := validation.BitArray().Sub(prs.Commits).PickRandom()
if ok { if ok {
rsig := validation.Commits[index]
commit := validation.Commits[index]
log.Debug("Picked commit to send", "index", index, "commit", commit)
// Reconstruct vote. // Reconstruct vote.
vote := &Vote{ vote := &Vote{
Height: prs.Height, Height: prs.Height,
Round: rsig.Round,
Round: commit.Round,
Type: VoteTypeCommit, Type: VoteTypeCommit,
BlockHash: header.LastBlockHash, BlockHash: header.LastBlockHash,
BlockParts: header.LastBlockParts, BlockParts: header.LastBlockParts,
Signature: rsig.Signature,
Signature: commit.Signature,
} }
msg := &VoteMessage{index, vote} msg := &VoteMessage{index, vote}
peer.Send(VoteCh, msg) peer.Send(VoteCh, msg)
ps.SetHasVote(vote, index) ps.SetHasVote(vote, index)
continue OUTER_LOOP continue OUTER_LOOP
} else {
log.Debug("No commits to send", "ours", validation.BitArray(), "theirs", prs.Commits)
} }
} }


+ 11
- 10
p2p/connection.go View File

@ -362,16 +362,17 @@ FOR_LOOP:
c.recvMonitor.Limit(maxMsgPacketSize, atomic.LoadInt64(&c.recvRate), true) c.recvMonitor.Limit(maxMsgPacketSize, atomic.LoadInt64(&c.recvRate), true)
// Peek into bufReader for debugging // Peek into bufReader for debugging
log.Debug("Peek connection buffer", "bytes", log15.Lazy{func() []byte {
numBytes := c.bufReader.Buffered()
bytes, err := c.bufReader.Peek(MinInt(numBytes, 100))
if err == nil {
return bytes
} else {
log.Warn("Error peeking connection buffer", "error", err)
return nil
}
}})
if numBytes := c.bufReader.Buffered(); numBytes > 0 {
log.Debug("Peek connection buffer", "bytes", log15.Lazy{func() []byte {
bytes, err := c.bufReader.Peek(MinInt(numBytes, 100))
if err == nil {
return bytes
} else {
log.Warn("Error peeking connection buffer", "error", err)
return nil
}
}})
}
// Read packet type // Read packet type
var n int64 var n int64


Loading…
Cancel
Save