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

Function Setup

app/export.go:282–347  ·  view source on GitHub ↗

Setup initializes a new AkashApp. A Nop logger is set in AkashApp.

(opts ...SetupAppOption)

Source from the content-addressed store, hash-verified

280
281// Setup initializes a new AkashApp. A Nop logger is set in AkashApp.
282func Setup(opts ...SetupAppOption) *AkashApp {
283 cfg := &setupAppOptions{
284 encCfg: sdkutil.MakeEncodingConfig(),
285 home: DefaultHome,
286 checkTx: false,
287 chainID: "akash-1",
288 }
289
290 ModuleBasics().RegisterInterfaces(cfg.encCfg.InterfaceRegistry)
291
292 for _, opt := range opts {
293 opt(cfg)
294 }
295
296 db := dbm.NewMemDB()
297
298 appOpts := viper.New()
299
300 appOpts.Set("home", cfg.home)
301
302 r := rand.New(rand.NewSource(0)) // nolint: gosec
303 genTime := simulation.RandTimestamp(r)
304
305 appOpts.Set("GenesisTime", genTime)
306
307 app := NewApp(
308 log.NewNopLogger(),
309 db,
310 nil,
311 true,
312 5,
313 map[int64]bool{},
314 cfg.encCfg,
315 appOpts,
316 baseapp.SetChainID(cfg.chainID),
317 )
318
319 if !cfg.checkTx {
320 var state GenesisState
321 if cfg.genesisFn == nil {
322 // init chain must be called to stop deliverState from being nil
323 state = NewDefaultGenesisState(app.AppCodec())
324 } else {
325 state = cfg.genesisFn(app.cdc)
326 }
327
328 stateBytes, err := json.MarshalIndent(state, "", " ")
329 if err != nil {
330 panic(err)
331 }
332
333 // Initialize the chain
334 _, err = app.InitChain(
335 &abci.RequestInitChain{
336 Validators: []abci.ValidatorUpdate{},
337 AppStateBytes: stateBytes,
338 ChainId: cfg.chainID,
339 },

Callers 4

setupTestFunction · 0.92
setupTestFunction · 0.92

Calls 6

ModuleBasicsFunction · 0.85
NewAppFunction · 0.85
NewDefaultGenesisStateFunction · 0.85
AppCodecMethod · 0.80
InitChainMethod · 0.80
RegisterInterfacesMethod · 0.45

Tested by 3

setupTestFunction · 0.74
setupTestFunction · 0.74