[viewchange] retry sending view change messages

retry is needed, as the next leader may not enter view change mode immediately
when other validators already sent out view change messages.
Then the new leader may not collect enough signatures for the new view before
timeout.

This can speed up the view change process.

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3388/head
Leo Chen 4 years ago
parent 6ce8aeac3d
commit 92130a2ba3
  1. 13
      consensus/view_change.go

@ -157,11 +157,16 @@ func (consensus *Consensus) startViewChange(viewID uint64) {
continue
}
msgToSend := consensus.constructViewChangeMessage(&key)
consensus.host.SendMessageToGroups([]nodeconfig.GroupID{
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)),
},
if err := consensus.msgSender.SendWithRetry(
consensus.blockNum,
msg_pb.MessageType_VIEWCHANGE,
[]nodeconfig.GroupID{
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID))},
p2p.ConstructMessage(msgToSend),
)
); err != nil {
consensus.getLogger().Err(err).
Msg("could not send out the ViewChange message")
}
}
}

Loading…
Cancel
Save