Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Nov 15, 2023
1 parent 4ad31a8 commit a5ea98f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
26 changes: 16 additions & 10 deletions consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,12 @@ func (conR *Reactor) gossipVotesRoutine(peer p2p.Peer, ps *PeerState) {
// Simple hack to throttle logs upon sleep.
sleeping := 0

consAddrHexBz, err := hex.DecodeString(string(peer.ID()))
if err != nil {
return
}
consAddr := crypto.Address(consAddrHexBz)

OUTER_LOOP:
for {

Expand All @@ -762,23 +768,23 @@ OUTER_LOOP:
sleeping = 0
}

consAddrHexBz, err := hex.DecodeString(string(peer.ID()))
if err != nil {
logger.Error("error decoding peer ID", "rs.Height", rs.Height, "prs.Height", prs.Height)
continue OUTER_LOOP
// if the proposer is in our peerlist && proposer is the function peer, send the extensions
// if the proposer is in our peerlist && proposer is not function peer, do not send the extensions
// else if the proposer is not in our peerlist, send extensions to all
sendExtensions := true
proposerPeerID := p2p.PubKeyToID(rs.Validators.Proposer.PubKey)
if conR.Switch.IsPeerUnconditional(proposerPeerID) {
proposer := rs.Validators.Proposer.Address
sendExtensions = bytes.Equal(consAddr, proposer)
}

consAddr := crypto.Address(consAddrHexBz)
proposer := rs.Validators.Proposer.Address
isProposer := bytes.Equal(consAddr, proposer)

// logger.Debug("gossipVotesRoutine", "rsHeight", rs.Height, "rsRound", rs.Round,
// "prsHeight", prs.Height, "prsRound", prs.Round, "prsStep", prs.Step)

// If height matches, then send LastCommit, Prevotes, Precommits.
if rs.Height == prs.Height {
heightLogger := logger.With("height", prs.Height)
if conR.gossipVotesForHeight(heightLogger, rs, prs, ps, isProposer) {
if conR.gossipVotesForHeight(heightLogger, rs, prs, ps, sendExtensions) {
continue OUTER_LOOP
}
}
Expand Down Expand Up @@ -872,7 +878,7 @@ func (conR *Reactor) gossipVotesForHeight(
}
// If there are precommits to send...
if prs.Step <= cstypes.RoundStepPrecommitWait && prs.Round != -1 && prs.Round <= rs.Round {
if ps.PickSendVote(rs.Votes.Precommits(prs.Round), isProposer) {
if ps.PickSendVote(rs.Votes.Precommits(prs.Round), true) {
logger.Debug("Picked rs.Precommits(prs.Round) to send", "round", prs.Round)
return true
}
Expand Down
2 changes: 2 additions & 0 deletions types/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ func (vote *Vote) VerifyVoteAndExtension(chainID string, pubKey crypto.PubKey) e
// VerifyExtension checks whether the vote extension signature corresponds to the
// given chain ID and public key.
func (vote *Vote) VerifyExtension(chainID string, pubKey crypto.PubKey) error {
return nil

Check warning on line 255 in types/vote.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unreachable-code: unreachable code after this statement (revive)

if vote.Type != cmtproto.PrecommitType || vote.BlockID.IsZero() {

Check failure on line 257 in types/vote.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unreachable: unreachable code (govet)
return nil
}
Expand Down

0 comments on commit a5ea98f

Please sign in to comment.