@@ -93,14 +93,14 @@ func (engine *Engine) Justified() (thor.Bytes32, error) {
9393 finalized := engine .Finalized ()
9494
9595 // if head is in the first epoch and not concluded yet
96- if head .Number () < getCheckPoint (engine .forkConfig .FINALITY )+ thor .CheckpointInterval - 1 {
96+ if head .Number () < getCheckPoint (engine .forkConfig .FINALITY )+ thor .EpochLength () - 1 {
9797 return finalized , nil
9898 }
9999
100100 // find the recent concluded checkpoint
101101 concluded := getCheckPoint (head .Number ())
102102 if head .Number () < getStorePoint (head .Number ()) {
103- concluded -= thor .CheckpointInterval
103+ concluded -= thor .EpochLength ()
104104 }
105105
106106 headChain := engine .repo .NewChain (head .ID ())
@@ -222,7 +222,7 @@ func (engine *Engine) ShouldVote(parentID thor.Bytes32) (bool, error) {
222222 }
223223
224224 // do not vote COM at the first round
225- if absRound := (block .Number (parentID )+ 1 )/ thor .CheckpointInterval - engine .forkConfig .FINALITY / thor .CheckpointInterval ; absRound == 0 {
225+ if absRound := (block .Number (parentID )+ 1 )/ thor .EpochLength () - engine .forkConfig .FINALITY / thor .EpochLength () ; absRound == 0 {
226226 return false , nil
227227 }
228228
@@ -252,7 +252,7 @@ func (engine *Engine) ShouldVote(parentID thor.Bytes32) (bool, error) {
252252 recentJC = checkpoint
253253 } else {
254254 // if current round is not justified, find the most recent justified checkpoint
255- prev , err := chain .GetBlockID (getStorePoint (block .Number (parentID ) - thor .CheckpointInterval ))
255+ prev , err := chain .GetBlockID (getStorePoint (block .Number (parentID ) - thor .EpochLength () ))
256256 if err != nil {
257257 return false , err
258258 }
@@ -381,15 +381,15 @@ func (engine *Engine) findCheckpointByQuality(target uint32, finalized, headID t
381381
382382 c := engine .repo .NewChain (headID )
383383 get := func (i int ) (uint32 , error ) {
384- id , err := c .GetBlockID (getStorePoint (searchStart + uint32 (i )* thor .CheckpointInterval ))
384+ id , err := c .GetBlockID (getStorePoint (searchStart + uint32 (i )* thor .EpochLength () ))
385385 if err != nil {
386386 return 0 , err
387387 }
388388 return engine .getQuality (id )
389389 }
390390
391391 // sort.Search searches from [0, n)
392- n := int ((block .Number (headID )- searchStart )/ thor .CheckpointInterval ) + 1
392+ n := int ((block .Number (headID )- searchStart )/ thor .EpochLength () ) + 1
393393 num := sort .Search (n , func (i int ) bool {
394394 quality , err := get (i )
395395 if err != nil {
@@ -413,7 +413,7 @@ func (engine *Engine) findCheckpointByQuality(target uint32, finalized, headID t
413413 return thor.Bytes32 {}, errors .New ("failed to find the block by quality" )
414414 }
415415
416- return c .GetBlockID (searchStart + uint32 (num )* thor .CheckpointInterval )
416+ return c .GetBlockID (searchStart + uint32 (num )* thor .EpochLength () )
417417}
418418
419419func (engine * Engine ) getTotalWeight (sum * chain.BlockSummary ) (* big.Int , error ) {
@@ -466,7 +466,7 @@ func (engine *Engine) getQuality(id thor.Bytes32) (quality uint32, err error) {
466466}
467467
468468func getCheckPoint (blockNum uint32 ) uint32 {
469- return blockNum / thor .CheckpointInterval * thor .CheckpointInterval
469+ return blockNum / thor .EpochLength () * thor .EpochLength ()
470470}
471471
472472func isCheckPoint (blockNum uint32 ) bool {
@@ -475,7 +475,7 @@ func isCheckPoint(blockNum uint32) bool {
475475
476476// save quality at the end of round
477477func getStorePoint (blockNum uint32 ) uint32 {
478- return getCheckPoint (blockNum ) + thor .CheckpointInterval - 1
478+ return getCheckPoint (blockNum ) + thor .EpochLength () - 1
479479}
480480
481481type mockedEngine thor.Bytes32
0 commit comments