Skip to content

Commit

Permalink
Merge pull request #5 from algorand/tsachi/ordertopics
Browse files Browse the repository at this point in the history
Ensure topics are ordered
  • Loading branch information
tsachiherman authored Jun 3, 2020
2 parents ea7c8bf + bcbed34 commit 7380d40
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gen/topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gen
import (
"bytes"
"fmt"
"sort"
"strings"
)

Expand All @@ -13,7 +14,15 @@ type Topics struct {
func (t *Topics) Bytes() []byte {
outbuf := bytes.NewBuffer(make([]byte, 0, 4096))
outbuf.WriteString("// The following msgp objects are implemented in this file:\n")
for key, values := range t.structs {

keys := []string{}
for key := range t.structs {
keys = append(keys, key)
}
sort.Strings(keys)

for _, key := range keys {
values := t.structs[key]
outbuf.WriteString(fmt.Sprintf("// %s\n", key))
spaces := len(key) / 2
for _, value := range values {
Expand Down

0 comments on commit 7380d40

Please sign in to comment.