Skip to content

Commit

Permalink
world/block.go: Merge Hash() and BaseHash() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedAsylumMC committed Sep 6, 2024
1 parent 6e71a3e commit 4a45f8b
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 1,045 deletions.
10 changes: 2 additions & 8 deletions cmd/blockhash/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ func procPackage(pkg *packages.Package, w io.Writer) {

var (
packageFormat = "// Code generated by cmd/blockhash; DO NOT EDIT.\n\npackage %v\n\n"
baseMethodFormat = "\nfunc (%v) BaseHash() uint64 {\n\treturn %v\n}\n"
hashMethodFormat = "\nfunc (%v%v) Hash() uint64 {\n\treturn %v\n}\n"
hashMethodFormat = "\nfunc (%v%v) Hash() (uint64, uint64) {\n\treturn %v, %v\n}\n"
constFormat = "\thash%v"
)

Expand Down Expand Up @@ -134,11 +133,6 @@ func (b *hashBuilder) writeNextHash(w io.Writer) {
}

func (b *hashBuilder) writeMethods(w io.Writer) {
for _, name := range b.names {
if _, err := fmt.Fprintf(w, baseMethodFormat, name, "hash"+name); err != nil {
log.Fatalln(err)
}
}
for _, name := range b.names {
fields := b.blockFields[name]

Expand Down Expand Up @@ -215,7 +209,7 @@ func (b *hashBuilder) writeMethods(w io.Writer) {
h = "0"
}

if _, err := fmt.Fprintf(w, hashMethodFormat, recvName, name, h); err != nil {
if _, err := fmt.Fprintf(w, hashMethodFormat, recvName, name, "hash"+name, h); err != nil {
log.Fatalln(err)
}
}
Expand Down
Loading

0 comments on commit 4a45f8b

Please sign in to comment.