-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add progress prints for v1.12 store migration #1557
Conversation
formatter := message.NewPrinter(language.English) | ||
migratedContracts := uint64(0) | ||
totalContracts := m.keeper.peekAutoIncrementID(ctx, types.KeyLastCodeID) | ||
previousTime := time.Now().UnixNano() |
Check warning
Code scanning / CodeQL
Calling the system time Warning
} | ||
migratedContracts++ | ||
logMigrationProgress(ctx, formatter, migratedContracts, totalContracts, previousTime) | ||
previousTime = time.Now().UnixNano() |
Check warning
Code scanning / CodeQL
Calling the system time Warning
func logMigrationProgress(ctx sdk.Context, formatter *message.Printer, migratedContracts uint64, totalContracts uint64, previousTime int64) { | ||
if migratedContracts%progressPartSize == 0 || migratedContracts == totalContracts { | ||
if totalContracts > 0 { | ||
timePerPartNs := time.Now().UnixNano() - previousTime |
Check warning
Code scanning / CodeQL
Calling the system time Warning
if migratedContracts%progressPartSize == 0 || migratedContracts == totalContracts { | ||
if totalContracts > 0 { | ||
timePerPartNs := time.Now().UnixNano() - previousTime | ||
partsLeft := float64(totalContracts-migratedContracts) / float64(progressPartSize) |
Check notice
Code scanning / CodeQL
Floating point arithmetic Note
if totalContracts > 0 { | ||
timePerPartNs := time.Now().UnixNano() - previousTime | ||
partsLeft := float64(totalContracts-migratedContracts) / float64(progressPartSize) | ||
timeLeftNs := uint64(partsLeft * float64(timePerPartNs)) |
Check notice
Code scanning / CodeQL
Floating point arithmetic Note
formatter.Sprintf("Migrated contracts: %d/%d (%f%%), ETA: %s\n", | ||
migratedContracts, | ||
totalContracts, | ||
(float64(migratedContracts)/float64(totalContracts))*100, |
Check notice
Code scanning / CodeQL
Floating point arithmetic Note
formatter.Sprintf("Migrated contracts: %d/%d (%f%%), ETA: %s\n", | ||
migratedContracts, | ||
totalContracts, | ||
(float64(migratedContracts)/float64(totalContracts))*100, |
Check notice
Code scanning / CodeQL
Floating point arithmetic Note
No description provided.