Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Nov 9, 2021
1 parent efe2df7 commit d5ed7b8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/results/data_results.go
Expand Up @@ -306,10 +306,9 @@ func ComputeCheckDataProgress(
}
tipIndex := networkStatus.CurrentBlockIdentifier.Index

// some blockchains don't start their genesis block from 0 height
// So take the height of genesis block and calculate tipIndex based on that
genesisBlockIndex := int64(0)
if networkStatus.GenesisBlockIdentifier != nil {
tipIndex -= networkStatus.GenesisBlockIdentifier.Index
genesisBlockIndex = networkStatus.GenesisBlockIdentifier.Index
}

// Get current tip in the case that re-orgs occurred
Expand Down Expand Up @@ -363,11 +362,14 @@ func ComputeCheckDataProgress(
new(big.Float).SetInt(elapsedTime),
)
blocksPerSecondFloat, _ := blocksPerSecond.Float64()

// some blockchains don't start their genesis block from 0 height
// So take the height of genesis block and calculate sync percentage based on that
blocksSynced := new(
big.Float,
).Quo(
new(big.Float).SetInt64(headBlock.Index),
new(big.Float).SetInt64(tipIndex),
new(big.Float).SetInt64(headBlock.Index - genesisBlockIndex),
new(big.Float).SetInt64(tipIndex - genesisBlockIndex),
)
blocksSyncedFloat, _ := blocksSynced.Float64()

Expand Down

0 comments on commit d5ed7b8

Please sign in to comment.