@@ -503,13 +503,24 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro
503503 header .Nonce = types.BlockNonce {}
504504
505505 number := header .Number .Uint64 ()
506+
507+ // Assemble the voting snapshot to check which votes make sense
508+ snap , err := c .snapshot (chain , number - 1 , header .ParentHash , nil )
509+ if err != nil {
510+ return err
511+ }
506512 if number % c .config .Epoch != 0 {
507513 c .lock .RLock ()
508- if len (c .proposals ) > 0 {
509- addresses := make ([]common.Address , 0 , len (c .proposals ))
510- for address := range c .proposals {
514+
515+ // Gather all the proposals that make sense voting on
516+ addresses := make ([]common.Address , 0 , len (c .proposals ))
517+ for address , authorize := range c .proposals {
518+ if snap .validVote (address , authorize ) {
511519 addresses = append (addresses , address )
512520 }
521+ }
522+ // If there's pending proposals, cast a vote on them
523+ if len (addresses ) > 0 {
513524 header .Coinbase = addresses [rand .Intn (len (addresses ))]
514525 if c .proposals [header .Coinbase ] {
515526 copy (header .Nonce [:], nonceAuthVote )
@@ -519,11 +530,7 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro
519530 }
520531 c .lock .RUnlock ()
521532 }
522- // Assemble the voting snapshot and set the correct difficulty
523- snap , err := c .snapshot (chain , number - 1 , header .ParentHash , nil )
524- if err != nil {
525- return err
526- }
533+ // Set the correct difficulty
527534 header .Difficulty = diffNoTurn
528535 if snap .inturn (header .Number .Uint64 (), c .signer ) {
529536 header .Difficulty = diffInTurn
0 commit comments