Skip to content

Commit

Permalink
fix flag parsing for common-index-block-sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed May 14, 2024
1 parent 188e797 commit 7563655
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Operators, you should copy/paste content of this content straight to your projec

If you were at `firehose-core` version `1.0.0` and are bumping to `1.1.0`, you should copy the content between those 2 version to your own repository, replacing placeholder value `fire{chain}` with your chain's own binary.

## v1.4.2 (Unreleased)

* Fix parsing of flag 'common-index-block-sizes' from yaml config file

## v1.4.1

### Substreams bumped to v1.6.1
Expand Down
14 changes: 13 additions & 1 deletion storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package firecore
import (
"context"
"fmt"
"strconv"
"strings"

"github.com/spf13/viper"
"github.com/streamingfast/dstore"
Expand Down Expand Up @@ -54,7 +56,17 @@ func GetIndexStore(dataDir string) (indexStore dstore.Store, possibleIndexSizes
indexStore = s
}

for _, size := range viper.GetIntSlice("common-index-block-sizes") {
sizes := viper.GetIntSlice("common-index-block-sizes")
if len(sizes) == 0 {
// viper doesn't parse ints from yaml file correctly
for _, k := range strings.Split(viper.GetString("common-index-block-sizes"), ",") {
if asInt, _err := strconv.ParseInt(k, 10, 64); _err == nil {
sizes = append(sizes, int(asInt))
}
}

}
for _, size := range sizes {
if size < 0 {
return nil, nil, fmt.Errorf("invalid negative size for common-index-block-sizes: %d", size)
}
Expand Down

0 comments on commit 7563655

Please sign in to comment.