-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR: init commit and merge confilict (#2731)
when repair-state we judge the fast-storage flag by data add feesplit module reserve --iavl-enable-fast-storage flag for repair-state merge repair-state we judge... and deal with confict rm NeedLongTimeToUpgrade use the IsFastStorgeStrategy universal Co-authored-by: xiangjianmeng <[email protected]>
- Loading branch information
1 parent
41ba5b3
commit 4e61647
Showing
8 changed files
with
260 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package appstatus | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
|
||
bam "github.com/okex/exchain/libs/cosmos-sdk/baseapp" | ||
"github.com/okex/exchain/libs/cosmos-sdk/client/flags" | ||
"github.com/okex/exchain/libs/cosmos-sdk/store/mpt" | ||
sdk "github.com/okex/exchain/libs/cosmos-sdk/types" | ||
"github.com/okex/exchain/libs/cosmos-sdk/x/auth" | ||
capabilitytypes "github.com/okex/exchain/libs/cosmos-sdk/x/capability/types" | ||
"github.com/okex/exchain/libs/cosmos-sdk/x/mint" | ||
"github.com/okex/exchain/libs/cosmos-sdk/x/params" | ||
"github.com/okex/exchain/libs/cosmos-sdk/x/supply" | ||
"github.com/okex/exchain/libs/cosmos-sdk/x/upgrade" | ||
"github.com/okex/exchain/libs/iavl" | ||
ibctransfertypes "github.com/okex/exchain/libs/ibc-go/modules/apps/transfer/types" | ||
ibchost "github.com/okex/exchain/libs/ibc-go/modules/core/24-host" | ||
dbm "github.com/okex/exchain/libs/tm-db" | ||
"github.com/okex/exchain/x/ammswap" | ||
dex "github.com/okex/exchain/x/dex/types" | ||
distr "github.com/okex/exchain/x/distribution" | ||
"github.com/okex/exchain/x/erc20" | ||
"github.com/okex/exchain/x/evidence" | ||
"github.com/okex/exchain/x/evm" | ||
"github.com/okex/exchain/x/farm" | ||
"github.com/okex/exchain/x/feesplit" | ||
"github.com/okex/exchain/x/gov" | ||
"github.com/okex/exchain/x/order" | ||
"github.com/okex/exchain/x/slashing" | ||
staking "github.com/okex/exchain/x/staking/types" | ||
token "github.com/okex/exchain/x/token/types" | ||
"github.com/okex/exchain/x/wasm" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const ( | ||
applicationDB = "application" | ||
dbFolder = "data" | ||
) | ||
|
||
func GetAllStoreKeys() []string { | ||
return []string{ | ||
bam.MainStoreKey, auth.StoreKey, staking.StoreKey, | ||
supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey, | ||
gov.StoreKey, params.StoreKey, upgrade.StoreKey, evidence.StoreKey, | ||
evm.StoreKey, token.StoreKey, token.KeyLock, dex.StoreKey, dex.TokenPairStoreKey, | ||
order.OrderStoreKey, ammswap.StoreKey, farm.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, | ||
ibchost.StoreKey, | ||
erc20.StoreKey, | ||
mpt.StoreKey, | ||
wasm.StoreKey, | ||
feesplit.StoreKey, | ||
} | ||
} | ||
|
||
func IsFastStorageStrategy() bool { | ||
return checkFastStorageStrategy(GetAllStoreKeys()) | ||
} | ||
|
||
func checkFastStorageStrategy(storeKeys []string) bool { | ||
home := viper.GetString(flags.FlagHome) | ||
dataDir := filepath.Join(home, dbFolder) | ||
db, err := sdk.NewDB(applicationDB, dataDir) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer db.Close() | ||
|
||
for _, v := range storeKeys { | ||
if !isFss(db, v) { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} | ||
|
||
func isFss(db dbm.DB, storeKey string) bool { | ||
prefix := fmt.Sprintf("s/k:%s/", storeKey) | ||
prefixDB := dbm.NewPrefixDB(db, []byte(prefix)) | ||
|
||
return iavl.IsFastStorageStrategy(prefixDB) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.