Skip to content

Commit

Permalink
Merge pull request #110 from oasisprotocol/matevz/order-gas-costs
Browse files Browse the repository at this point in the history
Sort network gas costs by its kind
  • Loading branch information
matevz authored Aug 9, 2023
2 parents a41c376 + d08bca2 commit 437cded
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/network/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (
"encoding/json"
"fmt"
"os"
"sort"
"strings"

"github.com/spf13/cobra"

"github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
consensusPretty "github.com/oasisprotocol/oasis-core/go/common/prettyprint"
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction"
registry "github.com/oasisprotocol/oasis-core/go/registry/api"
staking "github.com/oasisprotocol/oasis-core/go/staking/api"
"github.com/oasisprotocol/oasis-core/go/staking/api/token"
Expand Down Expand Up @@ -182,8 +184,15 @@ var showCmd = &cobra.Command{

fmt.Printf("Gas costs for network %s:", npa.PrettyPrintNetwork())
fmt.Println()
for kind, cost := range consensusParams.GasCosts {
fmt.Printf(" - %-26s %d", kind+":", cost)

// Print costs ordered by kind.
kinds := make([]string, 0, len(consensusParams.GasCosts))
for k := range consensusParams.GasCosts {
kinds = append(kinds, string(k))
}
sort.Strings(kinds)
for _, k := range kinds {
fmt.Printf(" - %-26s %d", k+":", consensusParams.GasCosts[transaction.Op(k)])
fmt.Println()
}
return
Expand Down

0 comments on commit 437cded

Please sign in to comment.