Skip to content

Commit 437cded

Browse files
authored
Merge pull request #110 from oasisprotocol/matevz/order-gas-costs
Sort network gas costs by its kind
2 parents a41c376 + d08bca2 commit 437cded

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

cmd/network/show.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import (
55
"encoding/json"
66
"fmt"
77
"os"
8+
"sort"
89
"strings"
910

1011
"github.com/spf13/cobra"
1112

1213
"github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
1314
consensusPretty "github.com/oasisprotocol/oasis-core/go/common/prettyprint"
15+
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction"
1416
registry "github.com/oasisprotocol/oasis-core/go/registry/api"
1517
staking "github.com/oasisprotocol/oasis-core/go/staking/api"
1618
"github.com/oasisprotocol/oasis-core/go/staking/api/token"
@@ -182,8 +184,15 @@ var showCmd = &cobra.Command{
182184

183185
fmt.Printf("Gas costs for network %s:", npa.PrettyPrintNetwork())
184186
fmt.Println()
185-
for kind, cost := range consensusParams.GasCosts {
186-
fmt.Printf(" - %-26s %d", kind+":", cost)
187+
188+
// Print costs ordered by kind.
189+
kinds := make([]string, 0, len(consensusParams.GasCosts))
190+
for k := range consensusParams.GasCosts {
191+
kinds = append(kinds, string(k))
192+
}
193+
sort.Strings(kinds)
194+
for _, k := range kinds {
195+
fmt.Printf(" - %-26s %d", k+":", consensusParams.GasCosts[transaction.Op(k)])
187196
fmt.Println()
188197
}
189198
return

0 commit comments

Comments
 (0)