Skip to content

Commit

Permalink
Reduce JSON marshal overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
avalkov committed Oct 21, 2024
1 parent 0f9a381 commit 0d730e6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/heimdallcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/ethereum/go-ethereum/console/prompt"
"github.com/ethereum/go-ethereum/crypto"
"github.com/google/uuid"
jsoniter "github.com/json-iterator/go"
hmModule "github.com/maticnetwork/heimdall/types/module"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -288,12 +287,14 @@ func generateMarshalledAppState(happ *app.HeimdallApp, chainID string, maxNextGe
"genesis_time": time.Now(),
}

marshaledAppState, err := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(genesisDoc)
if err != nil {
buf := new(bytes.Buffer)
encoder := json.NewEncoder(buf)
encoder.SetEscapeHTML(true)
if err = encoder.Encode(genesisDoc); err != nil {
return nil, err
}

return marshaledAppState, nil
return buf.Bytes(), nil
}

// getAppState generates and returns the app state.
Expand Down

0 comments on commit 0d730e6

Please sign in to comment.