Skip to content

Commit 58a1e13

Browse files
authored
Merge pull request ethereum#14657 from markya0616/refactor_clique
consensus/clique: fix typo and don't need to add snapshot into recents again
2 parents a1f3878 + 5c53a5b commit 58a1e13

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

consensus/clique/clique.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ var (
9999
// their extra-data fields.
100100
errExtraSigners = errors.New("non-checkpoint block contains extra signer list")
101101

102-
// drrInvalidCheckpointSigners is returned if a checkpoint block contains an
102+
// errInvalidCheckpointSigners is returned if a checkpoint block contains an
103103
// invalid list of signers (i.e. non divisible by 20 bytes, or not the correct
104104
// ones).
105-
drrInvalidCheckpointSigners = errors.New("invalid signer list on checkpoint block")
105+
errInvalidCheckpointSigners = errors.New("invalid signer list on checkpoint block")
106106

107107
// errInvalidMixDigest is returned if a block's mix digest is non-zero.
108108
errInvalidMixDigest = errors.New("non-zero mix digest")
@@ -297,7 +297,7 @@ func (c *Clique) verifyHeader(chain consensus.ChainReader, header *types.Header,
297297
return errExtraSigners
298298
}
299299
if checkpoint && signersBytes%common.AddressLength != 0 {
300-
return drrInvalidCheckpointSigners
300+
return errInvalidCheckpointSigners
301301
}
302302
// Ensure that the mix digest is zero as we don't have fork protection currently
303303
if header.MixDigest != (common.Hash{}) {
@@ -353,7 +353,7 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainReader, header *type
353353
}
354354
extraSuffix := len(header.Extra) - extraSeal
355355
if !bytes.Equal(header.Extra[extraVanity:extraSuffix], signers) {
356-
return drrInvalidCheckpointSigners
356+
return errInvalidCheckpointSigners
357357
}
358358
}
359359
// All basic checks passed, verify the seal and return
@@ -467,7 +467,6 @@ func (c *Clique) verifySeal(chain consensus.ChainReader, header *types.Header, p
467467
if err != nil {
468468
return err
469469
}
470-
c.recents.Add(snap.Hash, snap)
471470

472471
// Resolve the authorization key and check against signers
473472
signer, err := ecrecover(header, c.signatures)
@@ -479,13 +478,13 @@ func (c *Clique) verifySeal(chain consensus.ChainReader, header *types.Header, p
479478
}
480479
for seen, recent := range snap.Recents {
481480
if recent == signer {
482-
// Signer is among recents, only fail if the current block doens't shift it out
481+
// Signer is among recents, only fail if the current block doesn't shift it out
483482
if limit := uint64(len(snap.Signers)/2 + 1); seen > number-limit {
484483
return errUnauthorized
485484
}
486485
}
487486
}
488-
// Ensure that the difficulty corresponts to the turn-ness of the signer
487+
// Ensure that the difficulty corresponds to the turn-ness of the signer
489488
inturn := snap.inturn(header.Number.Uint64(), signer)
490489
if inturn && header.Difficulty.Cmp(diffInTurn) != 0 {
491490
return errInvalidDifficulty
@@ -604,7 +603,7 @@ func (c *Clique) Seal(chain consensus.ChainReader, block *types.Block, stop <-ch
604603
// If we're amongst the recent signers, wait for the next block
605604
for seen, recent := range snap.Recents {
606605
if recent == signer {
607-
// Signer is among recents, only wait if the current block doens't shift it out
606+
// Signer is among recents, only wait if the current block doesn't shift it out
608607
if limit := uint64(len(snap.Signers)/2 + 1); number < limit || seen > number-limit {
609608
log.Info("Signed recently, must wait for others")
610609
<-stop

0 commit comments

Comments
 (0)