Skip to content

Commit

Permalink
fix(icq-relayer): make "keys list" print out keys in a deterministic …
Browse files Browse the repository at this point in the history
…order

This ensures that new entries or removals can easily be tailed or
detected through simple checksumming.

Fixes quicksilver-zone#1522
  • Loading branch information
odeke-em committed Apr 30, 2024
1 parent 7f095c3 commit 7cb3e99
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions icq-relayer/cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sort"
"strings"

"golang.org/x/exp/maps"
"golang.org/x/term"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -194,8 +195,12 @@ $ %s k l ibc-1`, appName, appName)),
return err
}

for key, val := range info {
fmt.Printf("key(%s) -> %s\n", key, val)
// Ensure that the keys are printed in a deterministic order.
// Please see https://github.com/quicksilver-zone/quicksilver/issues/1522
keys := maps.Keys(info)
sort.Strings(keys)
for _, key := range keys {
fmt.Printf("key(%s) -> %s\n", key, info[key])
}

return nil
Expand Down

0 comments on commit 7cb3e99

Please sign in to comment.