MCPcopy Create free account
hub / github.com/akash-network/node / InitAkashAppForTestnet

Function InitAkashAppForTestnet

app/testnet.go:97–329  ·  view source on GitHub ↗

InitAkashAppForTestnet is broken down into two sections: Required Changes: Changes that, if not made, will cause the testnet to halt or panic Optional Changes: Changes to customize the testnet to one's liking (lower vote times, fund accounts, etc)

(
	app *AkashApp,
	db dbm.DB,
	tcfg *TestnetConfig,
)

Source from the content-addressed store, hash-verified

95// Required Changes: Changes that, if not made, will cause the testnet to halt or panic
96// Optional Changes: Changes to customize the testnet to one's liking (lower vote times, fund accounts, etc)
97func InitAkashAppForTestnet(
98 app *AkashApp,
99 db dbm.DB,
100 tcfg *TestnetConfig,
101) *AkashApp {
102 //
103 // Required Changes:
104 //
105
106 if tcfg == nil {
107 tmos.Exit("TestnetConfig cannot be nil")
108 }
109
110 var err error
111
112 defer func() {
113 if err != nil {
114 tmos.Exit(err.Error())
115 }
116 }()
117
118 ctx := app.NewUncachedContext(true, tmproto.Header{})
119
120 // STAKING
121 //
122
123 // Remove all validators from power store
124 stakingKey := app.GetKey(stakingtypes.ModuleName)
125 stakingStore := ctx.KVStore(stakingKey)
126 iterator, err := app.Keepers.Cosmos.Staking.ValidatorsPowerStoreIterator(ctx)
127 if err != nil {
128 panic(err.Error())
129 }
130 for ; iterator.Valid(); iterator.Next() {
131 stakingStore.Delete(iterator.Key())
132 }
133 _ = iterator.Close()
134
135 // Remove all validators from the last validators store
136 iterator, err = app.Keepers.Cosmos.Staking.LastValidatorsIterator(ctx)
137 if err != nil {
138 return nil
139 }
140 for ; iterator.Valid(); iterator.Next() {
141 stakingStore.Delete(iterator.Key())
142 }
143 _ = iterator.Close()
144
145 // Remove all validators from the validator store
146 iterator = storetypes.KVStorePrefixIterator(stakingStore, stakingtypes.ValidatorsKey)
147 for ; iterator.Valid(); iterator.Next() {
148 stakingStore.Delete(iterator.Key())
149 }
150 _ = iterator.Close()
151
152 // Remove all validators from unbonding queue
153 iterator = storetypes.KVStorePrefixIterator(stakingStore, stakingtypes.ValidatorQueueKey)
154 for ; iterator.Valid(); iterator.Next() {

Callers

nothing calls this directly

Calls 11

ErrorMethod · 0.65
GetKeyMethod · 0.65
DeleteMethod · 0.65
CloseMethod · 0.65
MintCoinsMethod · 0.65
HooksMethod · 0.65
GetMethod · 0.65
StoreLoaderMethod · 0.65
StringMethod · 0.45
InfoMethod · 0.45

Tested by

no test coverage detected