|
@ -63,6 +63,19 @@ func (ti *timeoutInfo) String() string { |
|
|
return fmt.Sprintf("%v ; %d/%d %v", ti.Duration, ti.Height, ti.Round, ti.Step) |
|
|
return fmt.Sprintf("%v ; %d/%d %v", ti.Duration, ti.Height, ti.Round, ti.Step) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type peerError struct { |
|
|
|
|
|
err error |
|
|
|
|
|
peerID p2p.ID |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (e peerError) Error() string { |
|
|
|
|
|
return fmt.Sprintf("error with peer %v: %s", e.peerID, e.err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
peerErrorEvent = "cs.PeerError" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// ConsensusState handles execution of the consensus algorithm.
|
|
|
// ConsensusState handles execution of the consensus algorithm.
|
|
|
// It processes votes and proposals, and upon reaching agreement,
|
|
|
// It processes votes and proposals, and upon reaching agreement,
|
|
|
// commits blocks to the chain and executes them against the application.
|
|
|
// commits blocks to the chain and executes them against the application.
|
|
@ -582,7 +595,8 @@ func (cs *ConsensusState) handleMsg(mi msgInfo) { |
|
|
// if the vote gives us a 2/3-any or 2/3-one, we transition
|
|
|
// if the vote gives us a 2/3-any or 2/3-one, we transition
|
|
|
err := cs.tryAddVote(msg.Vote, peerID) |
|
|
err := cs.tryAddVote(msg.Vote, peerID) |
|
|
if err == ErrAddingVote { |
|
|
if err == ErrAddingVote { |
|
|
// TODO: punish peer
|
|
|
|
|
|
|
|
|
// punish peer
|
|
|
|
|
|
cs.eventBus.Publish(peerErrorEvent, types.TMEventData{peerError{err, peerID}}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// NOTE: the vote is broadcast to peers by the reactor listening
|
|
|
// NOTE: the vote is broadcast to peers by the reactor listening
|
|
|