Skip to content

Commit

Permalink
Merge branch 'main' into feat/municipal-inflation
Browse files Browse the repository at this point in the history
  • Loading branch information
pbukva committed Aug 9, 2023
2 parents 5b3dc7d + 1d996e8 commit a93921c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions client/pruning/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ func PruningCmd(appCreator servertypes.AppCreator) *cobra.Command {
Use: "prune",
Short: "Prune app history states by keeping the recent heights and deleting old heights",
Long: `Prune app history states by keeping the recent heights and deleting old heights.
The pruning option is provided via the '--pruning' flag or alternatively with '--pruning-keep-recent'
The pruning strategy is provided via the '--pruning' flag or alternatively with '--pruning-keep-recent'
For '--pruning' the options are as follows:
default: the last 362880 states are kept
nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
everything: 2 latest states will be kept
custom: allow pruning options to be manually specified through 'pruning-keep-recent'.
custom: allow pruning options to be manually specified through the 'app.toml' config file or through CLI flags.
besides pruning options, database home directory and database backend type should also be specified via flags
'--home' and '--app-db-backend'.
valid app-db-backend type includes 'goleveldb', 'cleveldb', 'rocksdb', 'boltdb', and 'badgerdb'.
Expand Down Expand Up @@ -76,16 +76,20 @@ func PruningCmd(appCreator servertypes.AppCreator) *cobra.Command {
return fmt.Errorf("the database has no valid heights to prune, the latest height: %v", latestHeight)
}

var pruningHeights []int64
for height := int64(1); height < latestHeight; height++ {
if height < latestHeight-int64(pruningOptions.KeepRecent) {
pruningHeights = append(pruningHeights, height)
}
}
if len(pruningHeights) == 0 {
effectiveLastHeight := latestHeight - int64(pruningOptions.KeepRecent)

if effectiveLastHeight < 1 {
fmt.Printf("no heights to prune\n")
return nil
}

lenPH := effectiveLastHeight + 1
pruningHeights := make([]int64, lenPH)
for height := int64(1); height < lenPH; height++ {
pruningHeights[height] = height
}
pruningHeights = pruningHeights[1:]

fmt.Printf(
"pruning heights start from %v, end at %v\n",
pruningHeights[0],
Expand Down
2 changes: 1 addition & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func (rs *Store) PruneStores(clearStorePruningHeihgts bool, pruningHeights []int
pruningHeights = append(pruningHeights, rs.pruneHeights...)
}

if len(rs.pruneHeights) == 0 {
if len(pruningHeights) == 0 {
return
}

Expand Down

0 comments on commit a93921c

Please sign in to comment.