Skip to content

Commit

Permalink
chore: use NewOptions instead of AppyDefault
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <[email protected]>
  • Loading branch information
gfanton committed Oct 4, 2023
1 parent 977fe83 commit c87a7a6
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions gno.land/pkg/gnoland/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,11 @@ type AppOptions struct {
MaxCycles int64
}

func (c *AppOptions) ApplyDefault() {
if c.Logger == nil {
c.Logger = log.NewNopLogger()
}

if c.DB == nil {
c.DB = dbm.NewMemDB()
}

if c.GnoRootDir == "" {
c.GnoRootDir = GuessGnoRootDir()
func NewAppOptions() *AppOptions {
return &AppOptions{
Logger: log.NewNopLogger(),
DB: dbm.NewMemDB(),
GnoRootDir: GuessGnoRootDir(),
}
}

Expand All @@ -59,7 +53,7 @@ func (c *AppOptions) validate() error {
}

// NewApp creates the GnoLand application.
func NewAppWithOptions(cfg AppOptions) (abci.Application, error) {
func NewAppWithOptions(cfg *AppOptions) (abci.Application, error) {
if err := cfg.validate(); err != nil {
return nil, err
}
Expand Down Expand Up @@ -128,8 +122,7 @@ func NewAppWithOptions(cfg AppOptions) (abci.Application, error) {
func NewApp(dataRootDir string, skipFailingGenesisTxs bool, logger log.Logger, maxCycles int64) (abci.Application, error) {
var err error

var cfg AppOptions
cfg.ApplyDefault()
cfg := NewAppOptions()

// Get main DB.
cfg.DB, err = dbm.NewDB("gnolang", dbm.GoLevelDBBackend, filepath.Join(dataRootDir, "data"))
Expand Down

0 comments on commit c87a7a6

Please sign in to comment.