Skip to content

Commit b56710b

Browse files
committed
cmd,sqlite: add rebuild command
1 parent 107d34c commit b56710b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cmd/hostd/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ func main() {
257257
log.Fatal("failed to recalculate contract account funding", zap.Error(err))
258258
} else if err := db.CheckContractAccountFunding(); err != nil {
259259
log.Fatal("failed to check contract account funding", zap.Error(err))
260+
} else if err := db.Vacuum(); err != nil {
261+
log.Fatal("failed to vacuum database", zap.Error(err))
260262
}
261263
return
262264
}

persist/sqlite/recalc.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,23 @@ func recalcContractAccountFunding(tx txn, _ *zap.Logger) error {
8080
return nil
8181
}
8282

83+
// CheckContractAccountFunding checks that the contract account funding table
84+
// is correct.
8385
func (s *Store) CheckContractAccountFunding() error {
8486
return s.transaction(func(tx txn) error {
8587
return checkContractAccountFunding(tx, s.log)
8688
})
8789
}
8890

91+
// RecalcContractAccountFunding recalculates the contract account funding table.
8992
func (s *Store) RecalcContractAccountFunding() error {
9093
return s.transaction(func(tx txn) error {
9194
return recalcContractAccountFunding(tx, s.log)
9295
})
9396
}
97+
98+
// Vacuum runs the VACUUM command on the database.
99+
func (s *Store) Vacuum() error {
100+
_, err := s.db.Exec(`VACUUM`)
101+
return err
102+
}

0 commit comments

Comments
 (0)