From 9b7160b3fda7a12dd644b3f3cf967fd9b1bcf98f Mon Sep 17 00:00:00 2001 From: Alexandre Bourget Date: Wed, 12 Jun 2019 16:20:35 -0400 Subject: [PATCH] Added hex_rev_u32 to `tools names`. --- eosc/cmd/toolsNames.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/eosc/cmd/toolsNames.go b/eosc/cmd/toolsNames.go index ebed0de7..a8db6f76 100644 --- a/eosc/cmd/toolsNames.go +++ b/eosc/cmd/toolsNames.go @@ -4,6 +4,7 @@ import ( "encoding/binary" "encoding/hex" "fmt" + "math" "os" "regexp" "strconv" @@ -78,7 +79,7 @@ func printName(input string) { } someFound := false - rows := []string{"| from \\ to | hex | hex_be | name | uint64 | symbol | symbol_code", "| --------- | --- | ------ | ---- | ------ | ------ | ----------- |"} + rows := []string{"| from \\ to | hex | hex_be | hex_rev_u32 | name | uint64 | symbol | symbol_code", "| --------- | --- | ------ | ----------- | ---- | ------ | ------ | ----------- |"} for _, from := range []string{"hex", "hex_be", "name", "uint64", "symbol", "symbol_code"} { val, found := showFrom[from] if !found { @@ -87,7 +88,7 @@ func printName(input string) { someFound = true row := []string{from} - for _, to := range []string{"hex", "hex_be", "name", "uint64", "symbol", "symbol_code"} { + for _, to := range []string{"hex", "hex_be", "hex_rev_u32", "name", "uint64", "symbol", "symbol_code"} { cnt := make([]byte, 8) switch to { @@ -98,6 +99,15 @@ func printName(input string) { binary.BigEndian.PutUint64(cnt, val) row = append(row, hex.EncodeToString(cnt)) + case "hex_rev_u32": + if val > math.MaxUint32 { + row = append(row, "-") + } else { + cnt4 := make([]byte, 4) + binary.BigEndian.PutUint32(cnt4, math.MaxUint32-uint32(val)) + row = append(row, hex.EncodeToString(cnt4)) + } + case "name": row = append(row, eos.NameToString(val))