Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cabrador committed Nov 28, 2024
1 parent 91e7b80 commit 3a6cd1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
16 changes: 3 additions & 13 deletions cmd/sonictool/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,12 @@ func jsonGenesisImport(ctx *cli.Context) error {
return err
}

// 0 sets default value
stateDbCacheCapacity := 0
if ctx.IsSet(flags.StateDbCacheCapacityFlag.Name) {
stateDbCacheCapacity = ctx.Int(flags.StateDbCacheCapacityFlag.Name)
}

genesisJson, err := makefakegenesis.LoadGenesisJson(ctx.Args().First())
if err != nil {
return fmt.Errorf("failed to load JSON genesis: %w", err)
}

stateDbCacheCapacity := ctx.Int(flags.StateDbCacheCapacityFlag.Name)
genesisStore, err := makefakegenesis.ApplyGenesisJson(genesisJson, stateDbCacheCapacity)
if err != nil {
return fmt.Errorf("failed to prepare JSON genesis: %w", err)
Expand Down Expand Up @@ -131,17 +127,11 @@ func fakeGenesisImport(ctx *cli.Context) error {
return err
}

// 0 sets default value
stateDbCacheCapacity := 0
if ctx.IsSet(flags.StateDbCacheCapacityFlag.Name) {
stateDbCacheCapacity = ctx.Int(flags.StateDbCacheCapacityFlag.Name)
}

genesisStore := makefakegenesis.FakeGenesisStore(
idx.Validator(validatorsNumber),
futils.ToFtm(1000000000),
futils.ToFtm(5000000),
stateDbCacheCapacity,
ctx.Int(flags.StateDbCacheCapacityFlag.Name),
)
defer genesisStore.Close()
return genesis.ImportGenesisStore(ctx, genesisStore, dataDir, validatorMode, cacheRatio)
Expand Down
5 changes: 3 additions & 2 deletions config/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,9 @@ var (
Value: 0,
}
StateDbCacheCapacityFlag = cli.IntFlag{
Name: "statedb.cache",
Usage: "Cache size for StateDb instances. Carmen defaults 0 a hard-coded constant.",
Name: "statedb.cache",
Usage: "Size of StateDb instances cache in bytes. Leaving this blank (which is generally recommended), or setting" +
"this to <1 will automatically set the cache capacity a hard-coded constant.",
Value: 0,
}
)

0 comments on commit 3a6cd1e

Please sign in to comment.