Skip to content

Commit

Permalink
Clean up text and example code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taztingo committed Jan 5, 2024
1 parent 2ae72bf commit 2afc90a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
5 changes: 1 addition & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1077,11 +1077,8 @@ func New(
}
// --

// Verify configuration settings before boot
// storeLoader = DBBackendWrapper(app.Logger(), appOpts, storeLoader)
// Verify configuration settings
storeLoader = PruningWrapper(app.Logger(), appOpts, storeLoader)
// storeLoader = IAVLWrapper(storeLoader)
// storeLoader = ValidatorWrapper(storeLoader)
app.SetStoreLoader(storeLoader)

if loadLatest {
Expand Down
21 changes: 3 additions & 18 deletions app/store_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import (
"time"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
)

type StoreLoaderWrapper func(sdk.CommitMultiStore, baseapp.StoreLoader) error
Expand All @@ -31,30 +29,17 @@ func WrapStoreLoader(wrapper StoreLoaderWrapper, storeLoader baseapp.StoreLoader
}
}

// DBBackendWrapper creates a new StoreLoader that first validates the DBBackend type before calling the provided StoreLoader.
func DBBackendWrapper(logger log.Logger, appOpts servertypes.AppOptions, storeLoader baseapp.StoreLoader) baseapp.StoreLoader {
return WrapStoreLoader(func(ms sdk.CommitMultiStore, sl baseapp.StoreLoader) error {
backend := server.GetAppDBBackend(appOpts)
if backend != dbm.GoLevelDBBackend {
logger.Error(fmt.Sprintf("%s IS NO LONGER SUPPORTED. MIGRATE TO %s", backend, dbm.GoLevelDBBackend))
time.Sleep(30 * time.Second)
}

return sl(ms)
}, storeLoader)
}

// PruningWrapper creates a new StoreLoader that first validates the pruning settings before calling the provided StoreLoader.
func PruningWrapper(logger log.Logger, appOpts servertypes.AppOptions, storeLoader baseapp.StoreLoader) baseapp.StoreLoader {
return WrapStoreLoader(func(ms sdk.CommitMultiStore, sl baseapp.StoreLoader) error {
const MAX_PRUNING_INTERVAL = 100
const MaxPruningInterval = 100

// No error checking is needed because we leave that up to the sdk.
pruningString, _ := appOpts.Get("pruning-interval").(string)
interval, _ := strconv.ParseUint(pruningString, 10, 64)

if interval > MAX_PRUNING_INTERVAL {
logger.Error(fmt.Sprintf("pruning-interval %s IS INVALID AND CANNOT EXCEED %d", pruningString, MAX_PRUNING_INTERVAL))
if interval > MaxPruningInterval {
logger.Error(fmt.Sprintf("pruning-interval %s EXCEEDS %d AND IS NOT RECOMMENDED, AS IT CAN LEAD TO MISSED BLOCKS ON VALIDATORS", pruningString, MaxPruningInterval))
time.Sleep(30 * time.Second)
}

Check warning on line 44 in app/store_loader.go

View check run for this annotation

Codecov / codecov/patch

app/store_loader.go#L42-L44

Added lines #L42 - L44 were not covered by tests
return sl(ms)
Expand Down

0 comments on commit 2afc90a

Please sign in to comment.