@@ -58,19 +58,6 @@ func (c *core) handlePreprepare(msg *message, src istanbul.Validator) error {
5858 // Ensure we have the same view with the preprepare message
5959 // If it is old message, see if we need to broadcast COMMIT
6060 if err := c .checkMessage (msgPreprepare , preprepare .View ); err != nil {
61- if err == errOldMessage {
62- // Get validator set for the given proposal
63- valSet := c .backend .ParentValidators (preprepare .Proposal ).Copy ()
64- previousProposer := c .backend .GetProposer (preprepare .Proposal .Number ().Uint64 () - 1 )
65- valSet .CalcProposer (previousProposer , preprepare .View .Round .Uint64 ())
66- // Broadcast COMMIT if it is an existing block
67- // 1. The proposer needs to be a proposer matches the given (Sequence + Round)
68- // 2. The given block must exist
69- if valSet .IsProposer (src .Address ()) && c .backend .HasBlock (preprepare .Proposal .Hash (), preprepare .Proposal .Number ()) {
70- c .sendCommitForOldBlock (preprepare .View , preprepare .Proposal .Hash ())
71- return nil
72- }
73- }
7461 return err
7562 }
7663
@@ -100,21 +87,14 @@ func (c *core) handlePreprepare(msg *message, src istanbul.Validator) error {
10087
10188 // Here is about to accept the preprepare
10289 if c .state == StateAcceptRequest {
103- // If it is locked, it can only process on the locked block
104- // Otherwise, broadcast PREPARE and enter Prepared state
105- if c .current .IsHashLocked () {
106- // Broadcast COMMIT directly if the proposal matches the locked block
107- // Otherwise, send ROUND CHANGE
108- if preprepare .Proposal .Hash () == c .current .GetLockedHash () {
109- // Broadcast COMMIT and enters Prepared state directly
110- c .acceptPreprepare (preprepare )
111- c .setState (StatePrepared )
112- c .sendCommit ()
113- } else {
114- // Send round change
115- c .sendNextRoundChange ()
116- }
90+ // Send ROUND CHANGE if the locked proposal and the received proposal are different
91+ if c .current .IsHashLocked () && preprepare .Proposal .Hash () != c .current .GetLockedHash () {
92+ // Send round change
93+ c .sendNextRoundChange ()
11794 } else {
95+ // Either
96+ // 1. the locked proposal and the received proposal match
97+ // 2. we have no locked proposal
11898 c .acceptPreprepare (preprepare )
11999 c .setState (StatePreprepared )
120100 c .sendPrepare ()
0 commit comments